Skip to content

Support Jest coverageThreshold option #922

Description

@lacroixthomas

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:

Activity

  1. gaelollivier commented on Oct 25, 2016

    @gaelollivier
    Contributor

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

  2. mpj commented on Nov 18, 2016

    @mpj

    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.

  3. gaearon commented on Nov 20, 2016

    @gaearon
    Contributor

    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.

  4. gaelollivier commented on Nov 20, 2016

    @gaelollivier
    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

  5. gaearon commented on Nov 20, 2016

    @gaearon
    Contributor

    @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).

  6. devilleweppenaar commented on Dec 8, 2016

    @devilleweppenaar

    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",
  7. added this to the 1.0.0 milestone on Dec 8, 2016
  8. jagregory commented on Jan 12, 2017

    @jagregory

    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,
    };
  9. gaearon commented on Feb 24, 2017

    @gaearon
    Contributor

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

  10. jagregory commented on Mar 20, 2017

    @jagregory

    @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.

  11. Timer commented on Mar 21, 2017

    @Timer
    Contributor

    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.

  12. modified the milestones: , 1.0.0 on May 16, 2017
  13. gaearon commented on May 16, 2017

    @gaearon
    Contributor

    This is configurable in the next version.
    #1830

  14. gaearon commented on May 16, 2017

    @gaearon
    Contributor

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

  15. locked and limited conversation to collaborators on Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions