是否可以访问函数中的
ctx
对象,该函数将在 fixture.before 或 fixture.after 钩子中使用?
这是我自己试过的一段代码:
util.js
export function testCtxObject() {
ctx.test = '123'
}
test.js
import { testCtxObject } from 'util';
fixture('Access ctx object in fixture hooks')
.before(async (ctx) => {
testCtxObject();
});
...
当我在
test.js
中运行测试时,我最终得到这个错误:
1) - Error in fixture.before hook -
Cannot implicitly resolve the test run in the context of which the test controller
action should be executed. Use test function's 't' argument instead.