[英]How do I test a single file using yarn workspaces?
I know I can run a single test file using Jest .我知道我可以使用 Jest 运行单个测试文件。
I also know I can run all the tests in a single workspace with:我也知道我可以在一个工作区中运行所有测试:
yarn workspace @mycompany/somepackage test
But how would I run a single test file within a workspace?但是我如何在工作区内运行单个测试文件呢?
I have tried:我试过了:
yarn workspace @mycompany/somepackage test packages/somepackage/src/index.int.test.ts
and also:并且:
yarn workspace @mycompany/somepackage test src/index.int.test.ts
As I am unsure whether the 'test' expects paths relative to the workspace or not.因为我不确定“测试”是否需要相对于工作空间的路径。 Both fail with:
两者都失败了:
No tests found, exiting with code 1
I am using Yarn v1.22.7 and my tests use Jest.我正在使用 Yarn v1.22.7,我的测试使用 Jest。
How do I test a single file using Yarn workspaces?如何使用 Yarn 工作区测试单个文件?
You can run this command:您可以运行此命令:
yarn jest packages/somepackage/src/index.int.test.ts -c packages/somepackage/jest.config.js
you should change packages/somepackage/jest.config.js by exact path of your jest.config.js你应该通过你的 jest.config.js 的确切路径更改 packages/somepackage/jest.config.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.