stryker-mutator / stryker-js

Mutation testing for JavaScript and friends
https://stryker-mutator.io
Apache License 2.0
2.55k stars 242 forks source link

Enable parallelization for @stryker-mutator/jest-runner plugin #4861

Open raghav2008gupta opened 2 months ago

raghav2008gupta commented 2 months ago

Initial test run is taking too long

@stryker-mutator/jest-runner should allow parallelization

Slack thread with discussion details: https://stryker-mutator.slack.com/archives/CTYUW4B0E/p1714755891637819

nicojs commented 1 month ago

The main takeaways from that conversation:

  1. You're running StrykerJS with --incremental. This means most of the time is spent on the initial test run to calculate the test&mutant coverage matrix.
  2. Initial test run takes more than 3 minutes

In this scenario, a paralyzed initial test run would save a lot of time (assuming the CI runner has more than 2 cores).

Stryker config:

module.exports = {
  allowEmpty: true,
  checkers: ['typescript'],
  cleanTempDir: true,
  coverageAnalysis: 'perTest',
  ignorePatterns: [
    'packages/components/__tests__/atoms/Avatar/Avatar.test.tsx',
    'packages/components/__tests__/molecules/cards/ProfileSummary/ProfileSummary.test.tsx',
  ],
  ignoreStatic: true,
  incremental: true,
  jest: {
    projectType: 'custom',
    configFile: 'jest.config.js',
    enableFindRelatedTests: true,
  },
  mutate: [
    'packages/components/atoms/**/*.ts',
    'packages/components/atoms/**/*.js',
    'packages/components/molecules/**/*.ts',
    'packages/components/molecules/**/*.js',
    'packages/core/src/**/*.ts',
    'packages/core/src/**/*.js',
  ],
  reporters: ['progress', 'clear-text', 'html'],
  tempDirName: 'stryker-tmp',
  thresholds: {
    high: 95,
    low: 75,
    break: 64,
  },
  testRunner: 'jest',
  tsconfigFile: 'tsconfig.json',
};