1

I have the below structure and trying to run jest --testPathPattern=static/integration-tests to execute only the integration-tests. But I am seeing 0 matches. I tried even testRegex and other options too but in vain. Is my command right or is any modification required? FYI jest documentation doesn't have much description on the file patterns and I am completely new to the Javascript and ofcourse the Jest. Appreciate any help!

-resources
   |__package.json
   |__static
          |__unit-tests
          |          |__somescript.unit.test.js
          |
          |__integration-tests
                     |__somescript.int.test.js  
Hirein
  • 135
  • 5
  • 20
  • Your command should work as you expect. Could it be that you have a jest configuration (either in your package.json or in a separate file) that is adding additional configuration to filter out your test? – mgarcia Aug 28 '22 at 10:27
  • @mgarcia There is no additional config file. Below is the package.json script content and I would appreciate if you can provide me any working solution. "scripts":{ "integration-test": "jest --testPathPattern=static/integration-tests", "unit-test":"jest" } – Hirein Aug 29 '22 at 06:56
  • I don't know about any online editor that support changing package.json file. If you know where I can provide a working solution, I would be happy to oblige. – mgarcia Aug 29 '22 at 17:58

1 Answers1

0

I use a file naming scheme to distinguish unit and integration tests like you, this works for me:

jest --testRegex '\\.(?:unit)\\.test.js$'

jest --testRegex '\\.(?:int)\\.test.js$'

or if you want to run more than one kind of test:

jest --testRegex '\\.(?:unit|int)\\.test.js$'

Adam Malik
  • 345
  • 1
  • 7