Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stryker 4 beta: Typescript + React expressionMutantPlacer error with "BooleanLiteral" #2527

Closed
ovo-saxon-zerbino opened this issue Oct 6, 2020 · 1 comment · Fixed by #2530
Labels
🐛 Bug Something isn't working

Comments

@ovo-saxon-zerbino
Copy link

Summary

Trying to run stryker 4 beta on a react + typescript project and encountering an error during the expressionMutantPlacer step. The line that causes the error is:

const [expanded, setExpanded] = React.useState<string | false>('');

where the boolean literal false is attempting to be mutated. This issue can be worked around in my repo by replacing the above line with:

const [expanded, setExpanded] = React.useState<string | boolean>('');

Don't think this is a react specific issue, I think the mutator isn't detecting the boolean literal type correctly.

Stryker config

{
  "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
  "mutate": [
    "src/**/*.ts?(x)",
    "!src/**/*@(.test|.spec|Spec).ts?(x)"
  ],
  "testRunner": "jest",
  "reporters": [
    "progress",
    "clear-text",
    "html"
  ],
  "htmlReporter": { "baseDir": "coverage/mutation" },
  "coverageAnalysis": "off",
  "timeoutMS": 60000,
  "jest": {
    "projectType": "create-react-app",
    "enableFindRelatedTests": true
  },
  "maxConcurrentTestRunners": 6
}

Test runner config

Project built with CRA, jest config in package.json is:

"jest": {
    "collectCoverageFrom": [
      "**/*.{ts,tsx}",
      "!**/*.d.ts",
      "!**/node_modules/**",
      "!**/vendor/**",
      "!src/models/**",
      "!src/**/styles.ts",
      "!src/styles/**",
      "!src/serviceWorker.ts"
    ]
  }

Stryker environment

"@stryker-mutator/core": "^4.0.0-beta.10",
"@stryker-mutator/jest-runner": "^4.0.0-beta.10",
"@stryker-mutator/typescript-checker": "^4.0.0-beta.10",
"@stryker-mutator/jest-runner": "^4.0.0-beta.10",

Your Environment

software version(s)
node v14.9.0
npm v6.14.8 with yarn v1.22.5
Operating System macOS Catalina 10.15.7
@ovo-saxon-zerbino ovo-saxon-zerbino added the 🐛 Bug Something isn't working label Oct 6, 2020
@nicojs
Copy link
Member

nicojs commented Oct 7, 2020

Thanks! Should be an easy enough fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants