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 run fails with "UnexpectedToken" error #4839

Open
p-saxena opened this issue Apr 15, 2024 · 1 comment
Open

Stryker run fails with "UnexpectedToken" error #4839

p-saxena opened this issue Apr 15, 2024 · 1 comment
Labels
⁉ Question Further information is requested

Comments

@p-saxena
Copy link

Question

I am new to mutation testing and excited to introduce it to my team as part of our testing strategy. However, I am getting an error when trying to run (npx stryker run) it for the first time in our React frontend project. I would really appreciate all the help I can get to resolve this error. More details on it are below.

Stryker environment

+-- @stryker-mutator/[email protected]
+-- @stryker-mutator/[email protected]

Stryker config

{
  "testRunner": "jest",
  "reporters": [
    "progress",
    "clear-text",
    "html"
  ],
  "coverageAnalysis": "off",
  "jest": {
    "projectType": "create-react-app"
  },
  "logLevel": "trace",
  "allowConsoleColors": true,
  "checkers": [],
  "checkerNodeArgs": [],
  "commandRunner": {
    "command": "npm test"
  },
  "clearTextReporter": {
    "allowColor": true,
    "allowEmojis": false,
    "logTests": true,
    "maxTestsToLog": 3,
    "reportTests": true,
    "reportMutants": true,
    "reportScoreTable": true
  },
  "dashboard": {
    "baseUrl": "https://dashboard.stryker-mutator.io/api/reports",
    "reportType": "full"
  },
  "dryRunOnly": false,
  "eventReporter": {
    "baseDir": "reports/mutation/events"
  },
  "ignorePatterns": [],
  "ignoreStatic": false,
  "incremental": false,
  "incrementalFile": "reports/stryker-incremental.json",
  "force": false,
  "fileLogLevel": "off",
  "inPlace": false,
  "maxConcurrentTestRunners": 9007199254740991,
  "maxTestRunnerReuse": 0,
  "mutate": [
    "{src,lib}/**/!(*.+(s|S)pec|*.+(t|T)est).+(cjs|mjs|js|ts|mts|cts|jsx|tsx|html|vue|svelte)",
    "!{src,lib}/**/__tests__/**/*.+(cjs|mjs|js|ts|mts|cts|jsx|tsx|html|vue|svelte)"
  ],
  "mutator": {
    "plugins": null,
    "excludedMutations": []
  },
  "plugins": [
    "@stryker-mutator/*"
  ],
  "appendPlugins": [],
  "htmlReporter": {
    "fileName": "reports/mutation/mutation.html"
  },
  "jsonReporter": {
    "fileName": "reports/mutation/mutation.json"
  },
  "disableTypeChecks": true,
  "symlinkNodeModules": true,
  "tempDirName": ".stryker-tmp",
  "cleanTempDir": true,
  "testRunnerNodeArgs": [],
  "thresholds": {
    "high": 80,
    "low": 60,
    "break": null
  },
  "timeoutFactor": 1.5,
  "timeoutMS": 5000,
  "dryRunTimeoutMinutes": 5,
  "tsconfigFile": "tsconfig.json",
  "warnings": true,
  "disableBail": false,
  "allowEmpty": false,
  "ignorers": []
}

package.json

{
  "version": "3.372.0",
  "main": "server",
  "private": true,
  "license": "UNLICENSED",
  "dependencies": {
    "@react-hook/debounce": "^4.0.0",
    "apollo-datasource-rest": "^3.7.0",
    "aws-sdk": "^2.419.0",
    "body-parser": "1.18.3",
    "compression": "1.7.3",
    "connect-redis": "3.4.0",
    "cookie-parser": "^1.4.5",
    "dataloader": "^2.0.0",
    "dd-trace": "5.10.0",
    "debounce": "^1.2.1",
    "express": "4.16.4",
    "express-session": "1.15.6",
    "helmet": "^3.16.0",
    "isomorphic-fetch": "2.2.1",
    "query-string": "5.1.1",
    "ramda": "0.25.0",
    "react-table": "^7.7.0",
    "react-tabs": "^4",
    "request": "2.88.0",
    "ts-jest": "^27",
    "xlsx": "0.12.10"
  },
  "devDependencies": {
    "@apollo/client": "^3.5.6",
    "@braze/web-sdk": "^4.8.3",
    "@datadog/browser-rum": "^4.39.0",
    "@googlemaps/markerclustererplus": "^1.1.0",
    "@orq/superagent": "0.4.1",
    "@stryker-mutator/core": "^8.2.6",
    "@stryker-mutator/jest-runner": "^8.2.6",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^12.1.2",
    "@typescript-eslint/eslint-plugin": "^4",
    "@typescript-eslint/parser": "^5.25.0",
    "amplitude-js": "4",
    "apollo-server-express": "^2.18.2",
    "apollo-server-testing": "^2.21.1",
    "big.js": "^5",
    "chokidar-cli": "1.2.1",
    "classnames": "2.2.6",
    "csv-parse": "2.2.0",
    "d3": "^6.2.0",
    "dotenv": "6.2.0",
    "eslint-config-prettier": "^6.15.0",
    "eslint-import-resolver-typescript": "^2.7.1",
    "eslint-import-resolver-webpack": "^0.11.0",
    "eslint-plugin-import": "^2.26.0",
    "flow-bin": "^0.108.0",
    "flow-typed": "2.4.0",
    "folktale": "2.3.1",
    "got": "^9.6.0",
    "history": "^4.9.0",
    "http-proxy": "1.17.0",
    "husky": "^4",
    "jest-fetch-mock": "^3.0.3",
    "jest-styled-components": "^7.0.8",
    "js-cookie": "^2.2.1",
    "lint-staged": "^10.5.4",
    "lolex": "2.3.2",
    "marked": "0.3.19",
    "material-ui": "0.20.2",
    "mobx": "3.3.1",
    "mobx-react": "4.3.4",
    "moment": "^2.22.2",
    "nock": "9.2.5",
    "normalize.css": "8.0.1",
    "orq": "^0.3.0",
    "parse-decimal-number": "^1.0.0",
    "pdfjs-dist": "2.0.489",
    "prettier": "^2.2.0",
    "prop-types": "15.6.2",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-dropzone": "4.2.9",
    "react-ink": "6.4.0",
    "react-is": "18.2.0",
    "react-redux": "5.0.7",
    "react-router-config": "^5",
    "react-router-dom": "^5",
    "react-test-renderer": "18.2.0",
    "react-tunnels": "1.1.0",
    "redux": "4.0.1",
    "redux-actions": "2.3.0",
    "redux-promise-middleware": "5.1.1",
    "redux-thunk": "2.3.0",
    "reselect": "3.0.1",
    "rxjs": "5.5.10",
    "semver": "5.6.0",
    "spacetime": "7.4.7",
    "styled-components": "^5.2.1",
    "stylelint": "^13.11.0",
    "stylelint-config-prettier": "^8.0.2",
    "stylelint-config-styled-components": "^0.1.1",
    "stylelint-processor-styled-components": "^1.10.0",
    "typescript": "^4.3.4",
    "uuid": "^8.3.2"
  },
  "engines": {
    "node": "20"
  },
  "jest": {
    "testURL": "https://xxxxxx.com",
    "setupFilesAfterEnv": [
      "<rootDir>/__mocks__/automock"
    ],
    "setupFiles": [
      "<rootDir>/__mocks__/time"
    ],
    "moduleNameMapper": {
      "@braze/web-sdk": "<rootDir>/__mocks__/jestMockBraze.js"
    },
    "testPathIgnorePatterns": [
      "<rootDir>/node_modules/",
      "<rootDir>/cypress/",
      "dist"
    ],
    "testRegex": "(/__tests__/.*)\\.(j|t)sx?$",
    "transform": {
      "\\.ts": "ts-jest"
    },
    "collectCoverage": true,
    "coverageReporters": [
      "html",
      "text"
    ],
    "coverageDirectory": "coverage",
    "preset": "ts-jest",
    "moduleFileExtensions": [
      "ts",
      "js",
      "json"
    ]
  },
}

Stryker log

21:02:00 (97983) DEBUG PluginLoader Loading @stryker-mutator/* from /Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator
21:02:00 (97983) DEBUG PluginLoader Loading plugin "@stryker-mutator/jest-runner" (matched with expression @stryker-mutator/*)
21:02:00 (97983) DEBUG PluginLoader Loading plugin @stryker-mutator/jest-runner
21:02:00 (97983) DEBUG PluginLoader Loading plugin file:///Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/core/dist/src/reporters/index.js
21:02:00 (97983) DEBUG MetaSchemaBuilder Contributing 1 schemas from plugins to options validation.
21:02:02 (97983) INFO ProjectReader Found 1136 of 2847 file(s) to be mutated.

21:02:02 (97983) DEBUG TemporaryDirectory Using temp directory "/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/.stryker-tmp"
21:02:02 (97983) DEBUG Instrumenter Instrumenting 1136 source files with mutants
21:02:02 (97983) DEBUG Stryker Not removing the temp dir because an error occurred
21:02:02 (97983) ERROR Stryker Unexpected error occurred while running Stryker SyntaxError: /Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/src/client/bffmodelhydrators/Reminder/__fixtures__/index.js: Unexpected token, expected "," (8:7)

   6 | import { fixedMkReminders } from '#models/Reminders/__fixtures__'
   7 | import mkRemindersViews, {
>  8 |   type RemindersViews,
     |        ^
   9 |   type RemindersViewsOptions,
  10 | } from '../'
  11 |
    at constructor (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:353:19)
    at V8IntrinsicMixin.raise (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:3277:19)
    at V8IntrinsicMixin.unexpected (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:3297:16)
    at V8IntrinsicMixin.expect (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:3601:28)
    at V8IntrinsicMixin.parseNamedImportSpecifiers (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:13853:14)
    at V8IntrinsicMixin.parseImportSpecifiersAndAfter (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:13694:37)
    at V8IntrinsicMixin.parseImport (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:13687:17)
    at V8IntrinsicMixin.parseStatementContent (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:12347:27)
    at V8IntrinsicMixin.parseStatementLike (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:12239:17)
    at V8IntrinsicMixin.parseModuleItem (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:12216:17)
    at V8IntrinsicMixin.parseBlockOrModuleBlockBody (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:12796:36)
    at V8IntrinsicMixin.parseBlockBody (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:12789:10)
    at V8IntrinsicMixin.parseProgram (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:12116:10)
    at V8IntrinsicMixin.parseTopLevel (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:12106:25)
    at V8IntrinsicMixin.parse (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:13905:10)
    at parse (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:13947:38)
    at parser (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/lib/parser/index.js:41:34)
    at parser.next (<anonymous>)
    at parse (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/lib/parse.js:25:37)
    at parse.next (<anonymous>)
    at step (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/gensync/index.js:261:32)
    at /Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/gensync/index.js:273:13
    at async.call.result.err.err (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/gensync/index.js:223:11)
    at /Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/gensync/index.js:189:28
    at /Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/@stryker-mutator/instrumenter/node_modules/@babel/core/lib/gensync-utils/async.js:67:7
    at /Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/gensync/index.js:113:33
    at step (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/gensync/index.js:287:14)
    at /Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/gensync/index.js:273:13
    at async.call.result.err.err (/Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/gensync/index.js:223:11)
    at /Users/prateeksaxena/IdeaProjects/vimcar-frontend-fleet/node_modules/gensync/index.js:189:28
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3) {
  code: 'BABEL_PARSE_ERROR',
  reasonCode: 'UnexpectedToken',
  loc: Position { line: 8, column: 7, index: 260 },
  pos: 260
}
@p-saxena p-saxena added the ⁉ Question Further information is requested label Apr 15, 2024
@nicojs
Copy link
Member

nicojs commented Aug 6, 2024

This should be fixed with StrykerJS 8.3 (and now 8.4). Could you try it again?

We're using babel to parse files. Type imports are supported by later versions of babel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⁉ Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants