MCPcopy
hub / github.com/jestjs/jest / _partitionTests

Method _partitionTests

packages/jest-core/src/TestScheduler.ts:356–380  ·  view source on GitHub ↗
(
    testRunners: Record<string, JestTestRunner>,
    tests: Array<Test>,
  )

Source from the content-addressed store, hash-verified

354 }
355
356 private _partitionTests(
357 testRunners: Record<string, JestTestRunner>,
358 tests: Array<Test>,
359 ): Record<string, Array<Test>> | null {
360 if (Object.keys(testRunners).length > 1) {
361 return tests.reduce((testRuns, test) => {
362 const {config} = test.context;
363 const runnerKey = `${config.runner}\0${stableRunnerOptionsKey(config.runnerOptions)}`;
364 if (!testRuns[runnerKey]) {
365 testRuns[runnerKey] = [];
366 }
367 testRuns[runnerKey].push(test);
368 return testRuns;
369 }, Object.create(null));
370 } else if (tests.length > 0 && tests[0] != null) {
371 // If there is only one runner, don't partition the tests.
372 const {config} = tests[0].context;
373 const runnerKey = `${config.runner}\0${stableRunnerOptionsKey(config.runnerOptions)}`;
374 return Object.assign(Object.create(null), {
375 [runnerKey]: tests,
376 });
377 } else {
378 return null;
379 }
380 }
381
382 async _setupReporters(tests: Array<Test>) {
383 const {collectCoverage: coverage, notify} = this._globalConfig;

Callers 1

scheduleTestsMethod · 0.95

Calls 2

stableRunnerOptionsKeyFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected