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

Broken typescript config when using `extends`. #4776

Open george-kats opened 4 months ago

george-kats commented 4 months ago

Summary Broken tsconfig when using extends. Tests are running perfectly when pointing to config without relative extends.

ERROR Stryker Unexpected error occurred while running Stryker StrykerError: Error: An error occurred during initialization of the "typescript" checker. Inner error: Error: Typescript error(s) found in dry run compilation: tsconfig.stryker.json(1,161): error TS5069: Option 'tsBuildInfoFile' cannot be specified without specifying option 'incremental' or option 'composite'.

tsconfig.json

{
  "extends": "@libjs-utils/tsconfig",
  "compilerOptions": {
    "jsx": "react",
    "resolveJsonModule": true,
    "baseUrl": "./",
    "tsBuildInfoFile": "./buildcache/tsconfig.tsbuildinfo",
    "incremental": true,
    "typeRoots": ["@types", "node_modules/@types"],
    "paths": {
      "common/*": ["./src/common/*"],
      "@Checkout/*": ["./src/@Checkout/*"],
      "@PaymentDetails": ["./src/@PaymentDetails"],
      "@PaymentDetails/*": ["./src/@PaymentDetails/*"],
      "@PlanComparison/*": ["./src/@PlanComparison/*"],
      "@playwright/*": ["playwright/*"],
    }
  },
  "include": [
    "./src",
    "@types"
  ],
  "exclude": ["./src/__tests__/**/*"],
  "files": ["./config/jest/jest.setup.ts"]
}

tsconfig.stryker.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "skipLibCheck": true,
  },
}

Stryker config

module.exports = {
  $schema: './node_modules/@stryker-mutator/core/schema/stryker-schema.json',
  mutate: ['src/**/*.ts?(x)', '!src/**/*@(.test|.spec|Spec).ts?(x)'],
  testRunner: 'jest',
  jest: {
    projectType: 'custom',
    configFile: 'jest.config.json',
    enableFindRelatedTests: true,
  },
  checkers: ['typescript'],
  tsconfigFile: 'tsconfig.stryker.json',
  typescriptChecker: {
    prioritizePerformanceOverAccuracy: true,
  },
  reporters: ['progress', 'clear-text', 'html'],
  coverageAnalysis: 'perTest',
  ignoreStatic: true,
  incremental: true,
};

Stryker environment

├── @stryker-mutator/core@8.2.6
├── @stryker-mutator/jest-runner@8.2.6
├── @stryker-mutator/typescript-checker@8.2.6
├── stryker-api@0.24.1
├── stryker-html-reporter@0.18.1
├── stryker-jest-runner@1.4.1
├── stryker-typescript@0.18.1
├── @testing-library/jest-dom@6.4.2
├── @types/jest@29.5.12
├── jest-environment-jsdom@29.7.0
├── jest-sonar-reporter@2.0.0
├── jest@29.7.0

Test runner environment

yarn jest
{
  "clearMocks": true,
  "testResultsProcessor": "jest-sonar-reporter",
  "collectCoverageFrom": ["src/**/*.{ts,tsx}"],
  "coverageDirectory": "coverage",
  "collectCoverage": true,
  "moduleNameMapper": {
    "\\.(jpg|jpeg|png|webp|eot|otf|ttf|woff|woff2|gif)$": "<rootDir>/config/jest/__mocks__/fileMock.ts",
    "\\.(svg)$": "<rootDir>/config/jest/__mocks__/svgMock.ts",
    "\\.(scss|css)$": "identity-obj-proxy",
  },
  "roots": ["<rootDir>/src"],
  "moduleDirectories": ["node_modules", "src"],
  "setupFilesAfterEnv": ["<rootDir>/config/jest/jest.setup.ts"],
  "testMatch": ["<rootDir>/src/**/__tests__/**/*.spec.{ts,tsx}"],
  "testEnvironment": "jsdom",
  "globals": {
    "__DEV__": true,
    "CI_BUILD_VERSION": "release-123"
  }
}

Your Environment

software version(s)
node v20.11.1
npm 10.2.4
Operating System Sonoma 14.2.1

Add stryker.log

stryker.log

nicojs commented 4 months ago

Hi @george-kats-e thanks for opening this issue and sharing your configs. Should be a relatively easy fix.

@danny12321 if you feel up to it you might want to pick this up?

EDIT: @george-kats-e workaround for now is to remove the "tsBuildInfoFile": "./buildcache/tsconfig.tsbuildinfo" fro your config.

Or you could try changing your tsconfig.stryker.json:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "skipLibCheck": true,
+   "tsBuildInfoFile": null
  },
}