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

Return exit code 1 if coverage threshold requirements are not met on jest@20.0.0 #3520

Closed
honzabrecka opened this issue May 8, 2017 · 12 comments · Fixed by #3554
Closed

Comments

@honzabrecka
Copy link

honzabrecka commented May 8, 2017

Whenever the --coverage flag is passed, jest exits with 0 even if the threshold requirements are not met, but it should return non-zero exit code.

Worked before upgrade to jest@20.0.0.

@thymikee
Copy link
Collaborator

Cannot repro, fails with exit code 1 for 3 different projects. Have you tried purging node_modules?

@FQ400
Copy link

FQ400 commented May 10, 2017

I have the same issue. Downgrading from 20.0.0 to 19.0.2 fixed it.

andreffvalente pushed a commit to andreffvalente/jest that referenced this issue May 11, 2017
See: jestjs#3520

Fixed async calls to each reporter onRunComplete method
@andreffvalente
Copy link
Contributor

andreffvalente commented May 11, 2017

@thymikee You should reproduce the issue by setting the collectCoverageFrom in your Jest configuration. That forces the reporter to collect the coverage from untested files.

The Coverage reporter will not return a resolved promise when collectCoverageFrom matches files and consequently the Dispatcher will resolve the onRunComplete promise before collecting the result from reporter.

@thymikee
Copy link
Collaborator

cc @DmitriiAbramov

aaronabramov pushed a commit that referenced this issue May 12, 2017
* Return failure when coverage threshold isn’t met

See: #3520

Fixed async calls to each reporter onRunComplete method

* Run prettier
orta pushed a commit to orta/jest that referenced this issue Jul 7, 2017
* Return failure when coverage threshold isn’t met

See: jestjs#3520

Fixed async calls to each reporter onRunComplete method

* Run prettier
tushardhole pushed a commit to tushardhole/jest that referenced this issue Aug 21, 2017
* Return failure when coverage threshold isn’t met

See: jestjs#3520

Fixed async calls to each reporter onRunComplete method

* Run prettier
@jamsea
Copy link

jamsea commented Dec 13, 2017

I'm having the same issue, the merged PR doesn't seem to have fixed this for me. I'm going to do some more poking around

@jamsea
Copy link

jamsea commented Dec 19, 2017

Just a follow up in case anyone is brought here by Google:

Removing the projects node in jest.config.json fixed the issue. I also had to add:

  "resolutions": {
    "jest": "^21.2.1"
  }

To package.json (I'm using yarn), to make sure I was using the right version of jest.

I'll take a deeper look why removing projects fixed this. Guessing it's a similar issue with a race condition.

@akougblenou
Copy link

I don't have the projects node in my config but I still can get the coverage threshold to do it job, it is still returning an exit code of 0.

mrfyda added a commit to mrfyda/node-codacy-coverage that referenced this issue Jul 11, 2018
Changed script to execute independently of jest error code.
Looks like jest returns exit code 1 if coverage is under the defined goal when running in npm scripts: jestjs/jest#3520
@Sufiane
Copy link

Sufiane commented Nov 30, 2018

I still have this issue with jest@23.4.1.

Do I need to open a new issue?

@rickhanlonii
Copy link
Member

@Sufiane yes, please open a new issue if you have a reproduction on the latest Jest version 👌

@Sufiane
Copy link

Sufiane commented Dec 11, 2018

@rickhanlonii thanks for the response, i have done so. You can find the new issue here: #7450

@victorwads
Copy link

#6434 (comment)

I am using react-native-testing-library and what resolved this error for me was to simply make the callback of the test case async like

it('your test case', () => {...})

becomes:

it('your test case', async () => {...})

This worked for me, using react tests

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants