【发布时间】:2017-08-28 06:59:29
【问题描述】:
如何在 package.json 中使用 Jest --testNamePattern=<regex> 或 -t 选项
jest -t /.*flow.spec.js$/
或
jest -t='.*flow.spec.js$'
不起作用。
【问题讨论】:
如何在 package.json 中使用 Jest --testNamePattern=<regex> 或 -t 选项
jest -t /.*flow.spec.js$/
或
jest -t='.*flow.spec.js$'
不起作用。
【问题讨论】:
这种情况下的混淆是--testNamePattern 用于匹配测试套件中的测试名称而不是文件。提供的示例可能与预期不匹配:
describe('Test suite', () => {
test('something.flow.spec.js', () => {
//... tests here
});
});
要改为按文件名匹配,应使用--testPathPattern 参数。在这种情况下尝试:
--testPathPattern=.*flow.spec.js$
【讨论】: