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

Support Jest coverageThreshold option #922

Closed
lacroixthomas opened this issue Oct 18, 2016 · 12 comments
Closed

Support Jest coverageThreshold option #922

lacroixthomas opened this issue Oct 18, 2016 · 12 comments

Comments

@lacroixthomas
Copy link

lacroixthomas commented Oct 18, 2016

I would like to configure the coverage threshold from jest to be able to launch jenkins from CI with a 90-100% coverage.
Can we have support for this in Create react app ?

What is the most relevant:

@gaelollivier
Copy link
Contributor

Any insights on this ? Could be nice to provide custom config to Jest :)

@mpj
Copy link

mpj commented Nov 18, 2016

I would really like to be able to use the jest config options in package.json. Some of the defaults (such as bail=false) are very, very annoying. I don't think this would create much entropy.

@gaearon
Copy link
Contributor

gaearon commented Nov 20, 2016

Some of the defaults (such as bail=false) are very, very annoying.

File an issue and describe your use case? It’s really hard to guess that something is “very annoying” if nobody tells us about it. 😉 A lot of those might not be conscious decisions so you should question them in issues by explaining your use cases.

@gaelollivier
Copy link
Contributor

@gaearon What about the coverageTreshold then ? I don't think it can be a default, that's something that must be decided for each project

@gaearon
Copy link
Contributor

gaearon commented Nov 20, 2016

@gaelduplessix We intend to add some configurability in the future. I'm not closing the issue but now is not the time yet. Perhaps in a few months when more things shake out (e.g. Jest has been going through a ton of changes recently).

@devillecodes
Copy link

Jest configurability would be excellent, thanks!

For now, this is how we achieve coverage threshold checking on CI:

"coverage": "CI=true npm t -- --coverage",
"postcoverage": "istanbul check-coverage --statements 90 --functions 90 --branches 90 --lines 90",

@gaearon gaearon added this to the 1.0.0 milestone Dec 8, 2016
@jagregory
Copy link

Chiming in here (or should I raise a new issue?), but I'd like to be able to set the shapshotSerializers option for Jest so I can use enzyme and snapshot testing together transparently. See: https://www.npmjs.com/package/jest-serializer-enzyme

This would be trivial, if create-react-app allowed Jest configuration in package.json.

Naively, I'm wondering if utils/createJestConfig.js could be updated to merge package.json config if it exists. Something like:

const config = {
  collectCoverageFrom: ['src/**/*.{js,jsx}'],
  /* ... */
};

if (rootDir) {
  config.rootDir = rootDir;
}

return {
   ...config,
   ...packageJson.jest,
};

@gaearon
Copy link
Contributor

gaearon commented Feb 24, 2017

@jagregory You should be able to use expect.addSnapshotSerializer() in src/setupTests.js instead. Let me know if that works.

@jagregory
Copy link

@gaearon Do you know which Jest version that function is available? I'm using CRA 0.9.5, which has Jest 18.1.0, and I'm getting undefined function for expect.addSnapshotSerializer.

@Timer
Copy link
Contributor

Timer commented Mar 21, 2017

Looks like addSnapshotSerializer was added in Jest 19 which will be out in one of our 0.10 alpha releases, and (for sure) the stable.

@gaearon
Copy link
Contributor

gaearon commented May 16, 2017

This is configurable in the next version.
#1830

@gaearon gaearon closed this as completed May 16, 2017
@gaearon
Copy link
Contributor

gaearon commented May 16, 2017

Please help beta test the new version that includes this change!
#2172

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

7 participants