Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jest maxWorkers option is not available in configuration file

Tags:

jestjs

After I read through the docs. It seems to not have the option to set maxWorkers within the configuration files. I need to specify it in the cli.

Is there something that I'm missing here?

like image 657
lightbringer Avatar asked Oct 07 '17 01:10

lightbringer


People also ask

Where do I put Jest configuration?

The Jest philosophy is to work great by default, but sometimes you just need more configuration power. It is recommended to define the configuration in a dedicated JavaScript, TypeScript or JSON file. The file will be discovered automatically, if it is named jest.config.js|ts|mjs|cjs|json .

What is Jest configuration?

The jest. config. js file is used for configuring Jest, the JavaScript testing library used for writing unit and integration tests in Pup. The modulePaths property tells Jest where it can resolve NPM modules used inside of the code you're testing.

How does Jest recognize a test file?

The pattern Jest uses to detect test files. By default it looks for . js and . jsx files inside of __tests__ folders, as well as any files with a suffix of .

What is rootDir in Jest?

rootDir [string] Default: The root of the directory containing the package.json or the pwd if no package.json is found. Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.


1 Answers

Using [email protected], npx jest --init generates maxWorkers in jest.config.js. It's just not documented on the website.

// ...

module.exports = {
  // ...

  // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
  // maxWorkers: "50%",

  // ...
};
like image 128
Daniel T Avatar answered Oct 07 '22 21:10

Daniel T