stryker-mutator / stryker-js

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

The reason of the failing process is not clear #3924

Open kod-man opened 1 year ago

kod-man commented 1 year ago

Hi everybody, I was trying to use strykerJs in my react project. But I could not run the test unfortunately. And the reason was not clear to me. I followed the guide.

Here are my dependencies and dev-dependencies

"dependencies": { "@testing-library/jest-dom": "^5.16.1", "@testing-library/react": "^12.1.2", "core-js": "^3.14.0", "intl": "^1.2.5", "js-cookie": "^3.0.1", "moment": "^2.29.1", "og-merchant-portal-react-library": "^5.1.4", "react": "^16.8.6", "react-app-polyfill": "^2.0.0", "react-dom": "^16.8.6", "react-intl": "^2.9.0", "react-router": "^4.3.1", "react-router-dom": "^6.3.0", "react-scripts": "^3.4.4", "styled-components": "4.2.0" }, "scripts": { "build": "react-scripts build", "pro-build": "npx serve -s build -p 8000", "test": "react-scripts test", "eject": "react-scripts eject", "start-server": "node server.js", "start-js": "react-scripts start", "start": "set HTTPS=true&&npm-run-all --parallel start-js start-server", "lint": "node node_modules/eslint/bin/eslint.js --ext .jsx,.js src" }, "eslintConfig": { "extends": "react-app" }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] }, "devDependencies": { "@stryker-mutator/core": "^6.3.1", "@stryker-mutator/jest-runner": "^6.3.1", "@types/react-intl": "^3.0.0", "cors": "^2.8.5", "npm-run-all": "^4.1.5", "webpack": "^4.42.0" },

and also my config file

{
  "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
  "_comment": "This config was generated using 'stryker init'. Please see the guide for more information: https://stryker-mutator.io/docs/stryker-js/guides/react",
  "testRunner": "jest",
  "reporters": [
    "progress",
    "clear-text",
    "html"
  ],
  "coverageAnalysis": "off",
  "jest": {
    "projectType": "create-react-app"
  }
}

Here the terminal image

And the log image

Thanks for the answers in advance.

danny12321 commented 1 year ago

Hi @kod-man, the issue is that stryker couldn't find any tests. It is similar to #1691. The issue is that react-scripts doesn't support directories starting with a dot like we use for the sandbox .stryker-tmp. Using the setting "tempDirName": "stryker-tmp" in your stryker config should solve this problem.

kod-man commented 1 year ago

Hi @danny12321 Yes indeed. That was the fix. Thanks for your interest. Maybe adding these settings by default might be useful.

danny12321 commented 1 year ago

We tried to fix the source of the problem by opening an issue here facebook/create-react-app#7660. This issue has been created in 2019 but is still open. 😥 I don't think it is something we want to fix ourselves because it seems quite complex. The other solution is to add "tempDirName": "stryker-tmp" by default if using the create-react-app option in the Stryker cli like I have mentioned above. I think this is the best option for now, with some extra logging why this option is active (and that you should add this folder to your .gitignore).

@nicojs what is your opinion about this?

stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.