【发布时间】:2021-05-05 23:44:09
【问题描述】:
如果我有这样的规范文件:
let a;
beforeEach(() => {
a = 'hello';
})
describe('my test suite', () => {
test.each([
[a, 'hello']
])(
'testing %s with expected result %s',
(myVariable, expectedResult) => {
expect(myVariable).toBe(expectedResult);
})
});
我收到一个错误,指出参数化表中未定义 a。如果我使用常规的test 方法,我可以访问a。
【问题讨论】:
-
这能回答你的问题吗? Use variable expressions in test.each Jest
标签: javascript jestjs