3

I am currently running a create react app and writing unit tests with Jest and React Testing Library. I am running my unit tests with the following commands: npm test and npm run test:ci

All of my unit tests are passing successfully when running both npm test and npm run test:ci on my branch locally.

However my azure build pipeline is failing at the unit test step with 'exit status 1'

1 verbose cli   'test:ci' ]
2 info using npm@6.14.4
3 info using node@v10.20.1
4 verbose run-script [ 'pretest:ci', 'test:ci', 'posttest:ci' ]
5 info lifecycle repoName@0.1.0~pretest:ci: repoName
6 info lifecycle repoNames@0.1.0~test:ci: repoName@0.1.0
7 verbose lifecycle repoName@0.1.0~test:ci: unsafe-perm in lifecycle true
8 verbose lifecycle repoName@0.1.0~test:ci: PATH: /opt/hostedtoolcache/node/10.20.1/x64/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/vsts/work/1/s/node_modules/.bin:/opt/hostedtoolcache/node/10.20.1/x64/bin:/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin
9 verbose lifecycle repoName@0.1.0~test:ci: CWD: /home/vsts/work/1/s
10 silly lifecycle repoName@0.1.0~test:ci: Args: [ '-c',
10 silly lifecycle   'cross-env CI=true && react-scripts test --watchAll=false --all -reporters=default --reporters=jest-junit --coverage' ]
11 silly lifecycle repoName@0.1.0~test:ci: Returned: code: 1  signal: null
12 info lifecycle repoName@0.1.0~test:ci: Failed to exec test:ci script
13 verbose stack Error: repoName@0.1.0 test:ci: `cross-env CI=true && react-scripts test --watchAll=false --all -reporters=default --reporters=jest-junit --coverage`
13 verbose stack Exit status 1

Any insights into why this is happening or how I can find out exactly which test suite is failing?

Here Are snippets of my package.json

"jest": {
    "transform": {
      "^.+\\.tsx?$": "ts-jest"
    }
  },
    "scripts": {
        "test": "react-scripts test",
        "test:ci": "cross-env CI=true && react-scripts test --watchAll=false --all -reporters=default --reporters=jest-junit --coverage",
      }, 
"dependencies": {
    "react": "^16.10.1",
    "react-dom": "^16.10.1",
    "react-router-dom": "^5.1.2",
    "typescript": "3.6.3"
  },
"devDependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^10.0.3",
    "@testing-library/react-hooks": "^3.2.1",
    "@testing-library/user-event": "^10.1.0",
    "@types/jest": "^25.2.1",
    "@types/node": "12.7.10",
    "@types/react": "16.9.4",
    "@types/react-dom": "16.9.1",
    "@types/react-router-dom": "^5.1.0",
    "jest": "^24.9.0",
    "jest-environment-jsdom-sixteen": "^1.0.3",
    "ts-jest": "^25.4.0"
  }
skyboyer
  • 22,209
  • 7
  • 57
  • 64
  • Nikita, have you found the solution for your problem? If yes could you please share it here? I would appreciate a lot. – Grzegorz Solecki Sep 22 '21 at 12:19
  • 1
    @GrzegorzSolecki For me the issue was in the "Cannot log after tests are done. Did you forget to wait for something async in your test?" error while running tests. It didn't fail tests but did fail the pipeline. After resolving this error the pipeline got back to work. – Vadim S May 15 '22 at 20:48

0 Answers0