【发布时间】:2021-03-26 15:04:39
【问题描述】:
我想使用 testcafe 的 before 函数在每个夹具之前运行一个夹具或一组 testController 方法
我想在每个夹具提取到单独的函数之前运行夹具
// testSetup.ts
export async function initialiseTestEnv(t: testController) {
console.log("Initialise working env");
const docNameInput = Selector('input#documentName');
const createBtn = Selector('button.ui.primary.button');
await t
.useRole(roles.adminUser)
.maximizeWindow()
.navigateTo(testConfig.standardListPage)
.typeText(docNameInput, testConfig.repoName)
.click(createBtn);
我想在每个夹具之前运行它:
// tests.ts
// Tests that rely on env init
fixture `Tests that rely on init event`
.before(async t => {
await initialiseTestEnv(t)
})
.requestHooks(logger)
.beforeEach(async t => {
cookies.setCookies;
await t
.useRole(roles.adminUser)
})
test('Test that relies on test env init', async t => {...}
问题是之前没有我可以解析到 init 函数的测试控制器。是否有另一种方法可以在我运行的每个夹具之前运行这个初始化事件(我不想在每次测试之前运行,就在夹具之前)
【问题讨论】:
标签: typescript testing integration-testing e2e-testing testcafe