1

I know I can run a single test file using 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.

How do I test a single file using Yarn workspaces?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
mikemaccana
  • 110,530
  • 99
  • 389
  • 494

1 Answers1

1

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