pzrq
pzrq

Reputation: 1907

What happens if more than one Jest configuration is used simultaneously?

Jest's configuration states:

Jest's configuration can be defined in the package.json file of your project, or through a jest.config.js file or through the --config <path/to/js|json> option.

What happens if a configuration setting is defined in two or more places? Are distinct configuration settings merged together or can they be silently ignored? If merging or ignoring, do they have a well defined or ad hoc precedence?

Upvotes: 0

Views: 2611

Answers (1)

Julian Honma
Julian Honma

Reputation: 1824

I inherited multiple projects with both a "jest" object in package.json and "jest.config.js" file, each with their specific configuration.

By playing (superficially) with the coverage threshold (which was < 97%), I came to the conclusion that jest.config.js is used, and the jest object in package.json is ignored. There doesn't seem to be any merging going on.

My tests:

#1: Which has priority ?

  • package.json: coverage 98%
  • jest.config.js: coverage 99%
  • => "coverage threshold for statements (99%) not met"
  • Answer: jest.config.js

#2: Are they merged ?

  • package.json: coverage 98%
  • jest.config.js: (missing coverage key)
  • => no coverage warnings
  • Answer: No

Upvotes: 2

Related Questions