jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
44.16k stars 6.45k forks source link

No tests found on Windows with Jenkins #7441

Closed Saibamen closed 7 months ago

Saibamen commented 5 years ago

🐛 Bug Report

Tests are not executed on Windows

To Reproduce

Steps to reproduce the behavior:

  1. Write test file and save it in src folder as App.test.js
  2. npm run react-scripts test --env=jsdom --no-watchman or
  3. npm react-scripts test --env=jsdom --coverage

Expected behavior

Tests should be executed

Link to repl or repo (highly encouraged)

https://github.com/Saibamen/react_test

Run npx envinfo --preset jest

System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Xeon(R) CPU E5-2420 0 @ 1.90GHz
Binaries:
    Node: 10.13.0 - C:\Program Files\nodejs\node.EXE
    npm: 6.4.1 - C:\Users\jenkins\AppData\Roaming\npm\npm.CMD

npmPackages

"@coreui/coreui": "^2.1.1",
    "@coreui/icons": "0.3.0",
    "@coreui/react": "^2.1.0",
    "bootstrap": "^4.1.3",
    "classnames": "^2.2.6",
    "flag-icon-css": "^3.2.1",
    "font-awesome": "^4.7.0",
    "node-sass": "^4.10.0",
    "prop-types": "^15.6.2",
    "react": "^16.6.1",
    "react-dom": "^16.6.1",
    "react-helmet": "5.2.0",
    "react-loadable": "^5.5.0",
    "react-redux": "^5.1.0",
    "react-router-bootstrap": "^0.24.4",
    "react-router-dom": "^4.3.1",
    "react-router-redux": "^5.0.0-alpha.8",
    "react-scripts": "2.1.1",
    "reactstrap": "^6.5.0",
    "redux": "^4.0.1",
    "redux-immutable": "4.0.0",
    "redux-thunk": "^2.3.0",
    "rimraf": "^2.6.2",
    "simple-line-icons": "^2.4.1"

Actual Behavior

No tests found

react-scripts test --env=jsdom --no-watchman
00:02:06.736 
00:02:11.011 No tests found
00:02:11.011 In C:\Program Files (x86)\Jenkins\workspace\xxx\src\Web\xxx.Web\ClientApp
00:02:11.011   50 files checked.
00:02:11.011   testMatch: C:\Program Files \(x86\)\Jenkins\workspace\xxx\src\Web\xxx.Web\ClientApp\src\**\__tests__\**\*.{js,jsx,ts,tsx},C:\Program Files \(x86\)\Jenkins\workspace\xxx\src\Web\xxx.Web\ClientApp\src\**\?(*.)(spec|test).{js,jsx,ts,tsx} - 0 matches
00:02:11.011   testPathIgnorePatterns: \\node_modules\\ - 50 matches
00:02:11.011 Pattern:  - 0 matches
00:02:11.045 npm ERR! code ELIFECYCLE
00:02:11.046 npm ERR! errno 1
00:02:11.048 npm ERR! xxx@0.1.0 test:ci: `react-scripts test --env=jsdom --no-watchman`
00:02:11.049 npm ERR! Exit status 1
00:02:11.049 npm ERR! 
00:02:11.049 npm ERR! Failed at the xxx@0.1.0 test:ci script.
00:02:11.050 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
00:02:11.086 
00:02:11.087 npm ERR! A complete log of this run can be found in:
00:02:11.087 npm ERR!     C:\Users\jenkins\AppData\Roaming\npm-cache\_logs\2018-11-30T12_24_24_901Z-debug.log
00:02:11.109 Build step 'Execute Windows batch command' marked build as failure
rickhanlonii commented 5 years ago

@Saibamen thanks for reporting - quick question, how can we confirm that this is a Jest issue and not an issue with your configuration without a reproduction repo?

Saibamen commented 5 years ago

@richardscarrott because I didn't change anything in jest and react-scripts configuration (issue https://github.com/facebook/create-react-app/issues/5935).

This is similar to https://github.com/facebook/jest/issues/6257 (check my last comment)

Saibamen commented 5 years ago

@richardscarrott Reproduction repository: https://github.com/Saibamen/react_test

johnbowdenatfacet commented 5 years ago

Getting this too. I know with mocha you need to define the matches with quotes around the string, could be the issue?

vipul0805 commented 4 years ago

@richardscarrott Reproduction repository: https://github.com/Saibamen/react_test

Hi, i am facing the same issue here with jenkins on windows. Can you tell me how did you resolve this issue. `C:\Users\vipjinda.jenkins\workspace\reactPipeline>set CI=true && npm run coverage:prod -u

testing-react-app@0.1.0 coverage:prod C:\Users\vipjinda.jenkins\workspace\reactPipeline react-scripts test --coverage

No tests found, exiting with code 1 Run with --passWithNoTests to exit with code 0 In C:\Users\vipjinda.jenkins\workspace\reactPipeline 7 files checked. testMatch: C:/Users/vipjinda.jenkins/workspace/reactPipeline/src//tests//*.{js,jsx,ts,tsx}, C:/Users/vipjinda.jenkins/workspace/reactPipeline/src/*/.{spec,test}.{js,jsx,ts,tsx} - 0 matches testPathIgnorePatterns: \node_modules\ - 7 matches testRegex: - 0 matches Pattern: - 0 matches npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! testing-react-app@0.1.0 coverage:prod: react-scripts test --coverage npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the testing-react-app@0.1.0 coverage:prod script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

`

Saibamen commented 4 years ago

@vipul0805: Please retry by installing latest package versions from package.json. I think updating react-scripts should help

vipul0805 commented 4 years ago

Hi, I have all the latest versions installed.

On Thu, Mar 19, 2020, 13:19 Saibamen notifications@github.com wrote:

@vipul0805 https://github.com/vipul0805: Please retry by installing latest package versions from package.json. I think updating react-scripts should help

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601035868, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXQUAIS75ICWI5MDCYTRIHFCFANCNFSM4GHPTJ2Q .

Saibamen commented 4 years ago

Strange, this bug has gone for me after some update in CRA

Saibamen commented 4 years ago

@vipul0805: Do you have setupTests.js in src folder? My content:

import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });
vipul0805 commented 4 years ago

yes I have that in src folder. And what is CRA?

On Thu, Mar 19, 2020, 13:35 Saibamen notifications@github.com wrote:

@vipul0805 https://github.com/vipul0805: Do you have setupTests.js in src folder? My content:

import { configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601041730, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXSQL6G7WOXIOGE2NVDRIHG5BANCNFSM4GHPTJ2Q .

vipul0805 commented 4 years ago

can you share your package.json if possible?

On Thu, Mar 19, 2020, 13:49 Vipul Jindal aggarwal.vipul0805@gmail.com wrote:

yes I have that in src folder. And what is CRA?

On Thu, Mar 19, 2020, 13:35 Saibamen notifications@github.com wrote:

@vipul0805 https://github.com/vipul0805: Do you have setupTests.js in src folder? My content:

import { configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601041730, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXSQL6G7WOXIOGE2NVDRIHG5BANCNFSM4GHPTJ2Q .

Saibamen commented 4 years ago

CRA = Create React App

"dependencies": {
    "bootstrap": "^4.3.1",
    "classnames": "^2.2.6",
    "connected-react-router": "^6.6.1",
    "node-sass": "^4.13.1",
    "prop-types": "^15.7.2",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-helmet": "^5.2.1",
    "react-notification-system-redux": "^2.0.0",
    "react-rangeslider": "^2.2.0",
    "react-redux": "^7.1.1",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.3.1",
    "reactstrap": "^8.1.1",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "rimraf": "^3.0.1",
    "validator": "^12.2.0"
  },
  "scripts": {
    "start": "rimraf ./build && react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "test:ci": "react-scripts test --no-watchman",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "enzyme": "^3.11.0",
    "enzyme-adapter-react-16": "^1.15.2",
    "redux-mock-store": "^1.5.4",
    "stylelint-config-recommended": "^3.0.0"
  }
vipul0805 commented 4 years ago

You have different scripts in your medium blog and did you create a seperate jest config file or configured it in your package.json itself.

On Thu, Mar 19, 2020, 14:01 Saibamen notifications@github.com wrote:

CRA = Create React App

"dependencies": { "bootstrap": "^4.3.1", "classnames": "^2.2.6", "connected-react-router": "^6.6.1", "node-sass": "^4.13.1", "prop-types": "^15.7.2", "react": "^16.12.0", "react-dom": "^16.12.0", "react-helmet": "^5.2.1", "react-notification-system-redux": "^2.0.0", "react-rangeslider": "^2.2.0", "react-redux": "^7.1.1", "react-router-dom": "^5.1.2", "react-scripts": "3.3.1", "reactstrap": "^8.1.1", "redux": "^4.0.5", "redux-thunk": "^2.3.0", "rimraf": "^3.0.1", "validator": "^12.2.0" }, "scripts": { "start": "rimraf ./build && react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "test:ci": "react-scripts test --no-watchman", "eject": "react-scripts eject" }, "devDependencies": { "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.2", "redux-mock-store": "^1.5.4", "stylelint-config-recommended": "^3.0.0" }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601051615, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXXENCLJ7VPTBDVPZYLRIHJ6TANCNFSM4GHPTJ2Q .

Saibamen commented 4 years ago

I did not set some 3rd config. I left other parts of package.json as it is

vipul0805 commented 4 years ago

The problem I'm facing is in Jenkins as it's not able to find my test files.

On Thu, Mar 19, 2020, 14:40 Saibamen notifications@github.com wrote:

I did not set some 3rd config. I left other parts of package.json as it is

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601068810, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXWHF4MOZSQUBO6PHHDRIHORPANCNFSM4GHPTJ2Q .

Saibamen commented 4 years ago

Please provide your package.json

vipul0805 commented 4 years ago

I have attached package.json.

On Thu, Mar 19, 2020 at 3:15 PM Saibamen notifications@github.com wrote:

Please provide your package.json

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601084646, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXTJ65G6TZLG2FWKZRDRIHSU5ANCNFSM4GHPTJ2Q .

Saibamen commented 4 years ago

Where?

vipul0805 commented 4 years ago

it is attached in previous mail i sent you in attachments.

On Thu, Mar 19, 2020, 15:37 Saibamen notifications@github.com wrote:

Where?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601093862, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXXV7ZRXQX6AR5O5BTDRIHVEVANCNFSM4GHPTJ2Q .

vipul0805 commented 4 years ago

{ "name": "testing-react-app", "version": "0.1.0", "private": true, "dependencies": { "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.4.1", "@testing-library/user-event": "^7.2.1", "axios": "^0.19.2", "react": "^16.13.0", "react-dom": "^16.13.0", "react-scripts": "3.4.0" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "postbuild": "rimraf build//*.map", "test": "react-scripts test --env=jsdom", "coverage:dev": "react-scripts test --coverage --watchAll", "coverage:prod": "react-scripts test --coverage", "eject": "react-scripts eject" }, "jest": { "collectCoverageFrom": [ "*/.{js,jsx}", "!src/index.js", "!src/setupTests.js", "!coverage/", "!node_modules/", "!public/", "!build/**" ], "coverageReporters": [ "text", "lcov", "json", "text", "clover", "cobertura" ] }, "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": { "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.2", "sonarqube-scanner": "^2.5.0" } }

On Thu, Mar 19, 2020 at 3:51 PM Vipul Jindal aggarwal.vipul0805@gmail.com wrote:

it is attached in previous mail i sent you in attachments.

On Thu, Mar 19, 2020, 15:37 Saibamen notifications@github.com wrote:

Where?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601093862, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXXV7ZRXQX6AR5O5BTDRIHVEVANCNFSM4GHPTJ2Q .

Saibamen commented 4 years ago

Sending attachments by mail is not supported by GitHub. Please go to https://github.com/facebook/jest/issues/7441 and upload by comment form

vipul0805 commented 4 years ago

I've copy pasted the contents in previous mail. please check once.

On Thu, Mar 19, 2020, 15:54 Saibamen notifications@github.com wrote:

Sending attachments by mail is not supported by GitHub. Please go to #7441 https://github.com/facebook/jest/issues/7441 and upload by comment form

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601102273, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXRYD7STBBMJVFR347LRIHXFZANCNFSM4GHPTJ2Q .

Saibamen commented 4 years ago
  1. Replace test script to "test": "react-scripts test",
  2. Remove jest node
  3. Delete node_modules folder. If you are using Windows -> rmdir /s /q node_modules
  4. npm install
  5. npm test
  6. If npm test runs correctly in your local dev server, run in Jenkins
vipul0805 commented 4 years ago

Okay I'll try this.

On Thu, Mar 19, 2020, 16:15 Saibamen notifications@github.com wrote:

  1. Replace test script to "test": "react-scripts test",
  2. Remove jest node
  3. Delete node_modules folder. If you are using Windows -> rmdir /s /q node_modules
  4. npm install
  5. npm test
  6. If npm test runs correctly in your local dev server, run in Jenkins

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601111114, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXQCG65SCXB65KJ64PLRIHZUTANCNFSM4GHPTJ2Q .

vipul0805 commented 4 years ago

I have added this command to my jenkins file : bat "set CI=true && npm run coverage:prod -u" to run tests is this okay or any changes are required?

On Thu, Mar 19, 2020 at 4:21 PM Vipul Jindal aggarwal.vipul0805@gmail.com wrote:

Okay I'll try this.

On Thu, Mar 19, 2020, 16:15 Saibamen notifications@github.com wrote:

  1. Replace test script to "test": "react-scripts test",
  2. Remove jest node
  3. Delete node_modules folder. If you are using Windows -> rmdir /s /q node_modules
  4. npm install
  5. npm test
  6. If npm test runs correctly in your local dev server, run in Jenkins

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601111114, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXQCG65SCXB65KJ64PLRIHZUTANCNFSM4GHPTJ2Q .

Saibamen commented 4 years ago

Why you can't just try several ways and solutions? I think you are in work right now, so your Client will pay for your job...

vipul0805 commented 4 years ago

No I'm not at work and I've tried many ways but none of them is working.

On Thu, Mar 19, 2020, 16:31 Saibamen notifications@github.com wrote:

Why you can't just try several ways and solutions? I think you are in work right now, so your Client will pay for your job...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601117640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXQL5Y4TWU35VPSDINTRIH3QFANCNFSM4GHPTJ2Q .

vipul0805 commented 4 years ago

The coverage:prod That I've copied from someone's medium article. I'm not running any production build.

On Thu, Mar 19, 2020, 16:32 Vipul Jindal aggarwal.vipul0805@gmail.com wrote:

No I'm not at work and I've tried many ways but none of them is working.

On Thu, Mar 19, 2020, 16:31 Saibamen notifications@github.com wrote:

Why you can't just try several ways and solutions? I think you are in work right now, so your Client will pay for your job...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/jest/issues/7441#issuecomment-601117640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF2QZXQL5Y4TWU35VPSDINTRIH3QFANCNFSM4GHPTJ2Q .

ajo8571 commented 3 years ago

@Saibamen @vipul0805 Hello, I've run into this issue as well, yarn test works fine on my local machine but no test files are found in jenkins. Was there any resolution?

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

Saibamen commented 2 years ago

.

magua-io commented 1 year ago

This works for me: https://stackoverflow.com/questions/60604572/react-jest-no-tests-found-exiting-with-code-0

I used yarn test --watchAll=false --testMatch **/src/**/*.test.js on Windows Jenkins, and it works!

github-actions[bot] commented 8 months ago

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] commented 7 months ago

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] commented 6 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.