stryker-mutator / stryker-js

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

child process exited unexpectedly when multiple promises are awaited in a for loop #4011

Open magwas opened 1 year ago

magwas commented 1 year ago

Summary

When multiple promises are awaited in a for loop, jest gives correct test result (making sure all of them ran), while stryker reports error with 'child process exited unexpectedly'

Stryker does work if I use Promises.all(), but I would expect it to work correctly if the initial test is green.

The most minimal example I could reproduce the bug with is at https://github.com/kode-konveyor/cdd-ts/tree/bugreport/stryker_async

Stryker config

{
  "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
  "mutate": [
    "src/**/*.ts"
  ],
  "thresholds": {
    "low": 100,
    "high": 100
  },
  "ignoreStatic": false,
  "warnings": {
    "slow": false
  },
  "testRunner": "jest",
  "reporters": [
    "progress",
    "clear-text",
    "html",
    "json"
  ],
  "concurrency": 2,
  "coverageAnalysis": "perTest"
}

Test runner config Is in package.json

{
  "name": "cdd-ts",
  "version": "1.0.0",
  "description": "Test-time Contract Development framework for TypeScript",
  "main": "index.js",
  "type": "module",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "test": "jest"
  },
  "jest": {
    "preset": "ts-jest",
    "testEnvironment": "node"
  },
  "dependencies": {
    "@stryker-mutator/jest-runner": "^6.4.1",
    "fast-deep-equal": "^3.1.3",
    "fast-glob": "^3.2.12",
    "jest-mock": "^29.4.3",
    "tslib": "^2.3.0"
  },
  "devDependencies": {
    "@babel/preset-typescript": "^7.21.0",
    "@jest/globals": "^29.4.3",
    "@stryker-mutator/core": "^6.4.1",
    "@types/jest": "^29.4.0",
    "eslint": "^8.30.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-config-standard-with-typescript": "^24.0.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-n": "^15.6.0",
    "eslint-plugin-promise": "^6.1.1",
    "jasmine-core": "~4.5.0",
    "jest": "^28.1.3",
    "jest-mock-extended": "^3.0.3",
    "stryker-cli": "^1.0.2",
    "ts-jest": "^28.0.8",
    "typescript": "~4.8.2"
  }
}

Stryker environment

├── @stryker-mutator/core@6.4.1
├── @stryker-mutator/jest-runner@6.4.1
├── stryker-cli@1.0.2
├── @jest/globals@29.4.3
├── @stryker-mutator/jest-runner@6.4.1
├── @types/jest@29.4.0
├── jest-mock-extended@3.0.3
├── jest-mock@29.4.3
├── jest@28.1.3
├── ts-jest@28.0.8

Test runner environment

# npx jest

Your Environment

software version(s)
node v19.7.0
npm 9.5.1
Operating System Debian bullseye

Add stryker.log

stryker.log

danny12321 commented 1 year ago

Hi @magwas, I tried your example and saw the warnings stryker outputs which contains the errors jest throws. The run does continue and finishes eventually. Jest throws does errors because a mutant breaks the logic in the app.

For example the highlighted mutant below on row 19 replaces the / with an empty string. The path that's needs to be imported is now invalid an so it crashes the jest test runner. This crash is reported in the console and the mutant gets the status RuntimeError. image

Could you please try to wait a bit longer and see if stryker does continue with the warnings?