如何使用 Jest --testNamePattern=<regex>
或 -t
package.json 中的选项
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$
关于node.js - 在 package.json 中使用 Jest --testNamePattern=<regex> 或 -t 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45913349/