JimmyTheCode
JimmyTheCode

Reputation: 5714

Jest.config settings modulePathIgnorePatterns and testPathIgnorePatterns aren't having any effect

I'm running tests in a node app using jest. I can get tests running properly, but I can't seem to tell jest to ignore directories. For example, when I try to test a specific file convertExistingImages.ts with the command: npm test convertExistingImages I get a response in my terminal of:

> [email protected] test
> jest

 FAIL  dist/utils/maintenance.ts/convertExistingImages.test.js
  ● Test suite failed to run

    Your test suite must contain at least one test.
  (...)
 FAIL  src/utils/maintenance/convertExistingImages.test.ts
  ● Test suite failed to run
  (...)

As you can see, a duplicate file in my /dist folder is also being tested, which I don't want.

I've tried updating my jest.config.ts file as follows:

module.exports = {
  "preset": "@shelf/jest-mongodb",
  "modulePathIgnorePatterns": ["/build/"],
  "testPathIgnorePatterns": ["/node_modules/", "/build/"]
}

But the modulePathIgnorePatterns and testPathIgnorePatterns settings aren't having any effect.

Can anyone tell me what I'm doing wrong?

Upvotes: 0

Views: 2385

Answers (1)

Ian
Ian

Reputation: 2620

You configured it to ignore the build folder but your conflict is in the dist folder. Change build to dist in your ignore settings.

You can read more about this config on the Jest site here.

Upvotes: 2

Related Questions