javascriptjestjsvisual-web-developer-2010

JEST testPathPattern not recognizing integration tests


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  

Solution

  • 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$'