[英]how to call all test in one folder using jest pattern matching?
I have my regular unit tests in folders with my services 我的服务在文件夹中进行常规单元测试
Now I created new folder called integration/
and inside this folder all my tests look like anotherFolder/testSomeApi.integration.js
现在,我创建了一个名为
integration/
新文件夹,并且在该文件夹中,所有测试都看起来像anotherFolder/testSomeApi.integration.js
I did this, so that when I call node jest
, it runs all the unit tests but not the integration tests. 我这样做是为了让我在调用
node jest
时运行所有单元测试,而不运行集成测试。 I want to call integration tests from my docker container with separate command 我想用单独的命令从我的Docker容器调用集成测试
How can I call something like jest *integration.js
so that all tests in integration folder with extension integration.js
gets called? 如何调用诸如
jest *integration.js
以便调用扩展名为integration.js
Integration文件夹中的所有测试?
Inside your integration folder create a config file for jest, eg jest-integration.json 在您的集成文件夹中,为jest创建一个配置文件,例如jest-integration.json
{
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".integration.js$",
}
Now you can run jest from your project root like so: 现在,您可以从项目根目录运行jest,如下所示:
jest --config ./integration/jest-integration.json
You could save this line as an NPM script in your package.json and use it like 您可以将该行另存为package.json中的NPM脚本,并像
npm run test:integration
. npm run test:integration
。
最后我做了
jest "(/integration/.*|\\\\.(integration))\\\\.(js)$"
jest --testPathPattern=".*/folderName/.*.spec.ts"
为我工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.