Jest: Specify which tests to run in a scalable way

Created on 31 Aug 2017  路  4Comments  路  Source: facebook/jest

I hit a performance problem trying to run to many tests.

I call jest with jest test1.js test2.js test3.js ... test9999.js
which eventually gets transformed into a regexp by
https://github.com/facebook/jest/blob/master/packages/jest-config/src/normalize.js#L289

and used to match agains every test file to figure out whether we want to run it or not.

It works on small runs, but when i send a few thousand test paths it slows down the process a lot.

The solution i'm thinking about is to have a --runTestPaths flag that will tell jest not to use regexp matching logic to find tests, but rather match by relative patch.

if (config.runTestPaths) {
  const testsToRun = new Set(argv._);
}

// later in the code
const testsToRun = allTests.filter(testPath => testsToRun.has(testPath);

@mjesun

Most helpful comment

--runTestsByPath, then, maybe?

All 4 comments

Could we instead run all the tests? If it's a few thousand test files, that seems like it captures most tests.

I'm a bit worried about adding yet another config option to control running of tests, the CLI is becoming a bit of a mess :(

The issue happens when you have a filtered list of tests that is a subset of all tests.

@cpojer i agree about CLI becoming a mess, but we really need this :(
this is not an --all scenario.
If you touch a critical file (for example flux_dispatcher.js) that used in many files in a particular project (for example Ads) it will try to run most of Ads tests (not all of www, just ads, which is still a lot), and then filter out the tests that are known as flaky or failing.
So we can't run all with excluded tests either here :(

--runTestsByPath, then, maybe?

Was this page helpful?
0 / 5 - 0 ratings