admin管理员组

文章数量:1426058

I have a node application with separate sister folders and acpanying package.json files for the application code and tests.

Project
|
|-----Application
          |-----app.js
          |-----package.json
|-----Tests
        |
        |-------test.js
        |-------package.json  (nyc added here)

nyc is included as a dependency(along with mocha) in the test folder. It fails to show coverage for files in the application folder. I have tried to explicitly include application files by including "../Application/**/*.js" in the nyc config, bit that does not seem to do the trick.

Any ideas?

I have a node application with separate sister folders and acpanying package.json files for the application code and tests.

Project
|
|-----Application
          |-----app.js
          |-----package.json
|-----Tests
        |
        |-------test.js
        |-------package.json  (nyc added here)

nyc is included as a dependency(along with mocha) in the test folder. It fails to show coverage for files in the application folder. I have tried to explicitly include application files by including "../Application/**/*.js" in the nyc config, bit that does not seem to do the trick.

Any ideas?

Share Improve this question asked Nov 20, 2018 at 18:14 arinrayarinray 2162 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

I found out that you can do this by using an obscure option called cwd as follows:

  "nyc": {
    "all": true,
    "check-coverage": true,
    "per-file": true,
    "lines": 99,
    "statements": 99,
    "functions": 99,
    "branches": 99,
    **"cwd" : "../",**
    "exclude" : [
      "Tests/**/*.js"
    ]
  }

本文标签: javascriptEnabling nycistanbul code coverage for files outside the package directoryStack Overflow