Skip to content

Does c8 support config files? #274

Closed

Description

@marktyers

Rather than specifying the settings as flags is there support for including a config file (json format)?

This could be standalone, for example:
.ava.config.json

Or included in the package manifest package.json. Perhaps using the same format as jest?

{
  "name": "my-project",
  "ava": {
    "coverageThreshold": {
      "global": {
        "branches": 80,
        "functions": 80,
        "lines": 80,
        "statements": -10
      }
  }
}

Activity

  1. bcoe commented on Dec 30, 2020

    @bcoe
    Owner

    @marktyers you can provide a .nycrc.json or a .c8.json configuration file. It accepts all the same keys accepted by the CLI:

    https://github.com/bcoe/c8/blob/master/.nycrc

    Seems like an oversight that it's not documented.

  2. bcoe commented on Dec 30, 2020

    @bcoe
    Owner

    Oh, I should also add, once you have this configuration file you can create a badge based on it:

    https://shields.io/category/coverage

  3. XhmikosR commented on Feb 1, 2021

    @XhmikosR
    Contributor

    @bcoe .nycrc works, but it seems a package.json config key of nyc does not work (it works with nyc, though). Is that supposed to work too?

    EDIT:

    it seems it works if I use c8 as the package.json key. I'm still not sure if it's a bug or not :)

  4. bcoe commented on Feb 4, 2021

    @bcoe
    Owner

    @XhmikosR for easy migration from old projects, I decided to support both .c8rc and .nycrc, for package configuration I think it was intentional that it supports only c8.

    Sounds like you're unblocked?

  5. XhmikosR commented on Feb 4, 2021

    @XhmikosR
    Contributor

    Yeah. But this issue is still valid; there's no documentation about which config files are supported :)

  6. SalahAdDin commented on Jun 26, 2022

    @SalahAdDin

    @marktyers you can provide a .nycrc.json or a .c8.json configuration file. It accepts all the same keys accepted by the CLI:

    https://github.com/bcoe/c8/blob/master/.nycrc

    Seems like an oversight that it's not documented.

    Yeah, it is not still documented, so, it is not clear.

  7. Wambosa commented on Jan 11, 2024

    @Wambosa

    for future engineers who just want a tldr example json

    old package.json:

        "test:ci": "cross-env NODE_OPTIONS=--enable-source-maps npx c8 --check-coverage --branches 80 --functions 80 --lines 80 --statements 80 --exclude 'build/dev/unit/**' --exclude 'build/dev/mock/**' --reports-dir ./build/ jasmine --config=config/jasmine-unit.json",
    

    translates to this config file (/config/.c8rc):

    {
      "check-coverage": true,
      "reports-dir": "./build/",
      "branches": 80,
      "functions": 80,
      "lines": 80,
      "statements": 80,
      "exclude": [
        "build/dev/unit/**",
        "build/dev/mock/**"
      ]
    }
    

    which makes us update our package.json command to:

    "test:ci2": "cross-env NODE_OPTIONS=--enable-source-maps npx c8 --config ./config/.c8rc jasmine --config=config/jasmine-unit.json",
    

    ps love c8, been using it for years. Thank y'all 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions