code-coverage icon indicating copy to clipboard operation
code-coverage copied to clipboard

Cannot find coverage file .nyc_output/out.json in the automated build.

Open Muthu2190 opened this issue 3 years ago • 8 comments

I have followed this example for my project https://github.com/bahmutov/next-and-cypress-example and i can get the output in the .nyc_output folder while running in local env, but not in the automated build.

package.json:

"devDependencies": {
    "cy-verify-downloads": "0.0.5",
    "cypress": "8.6.0",
    "cypress-file-upload": "^5.0.8",
    "typescript": "^4.4.3",
    "@cypress/browserify-preprocessor": "^3.0.1",
    "@cypress/code-coverage": "^3.8.1",
    "@istanbuljs/nyc-config-typescript": "^1.0.1",
    "@testing-library/cypress": "^7.0.1",
    "@types/testing-library__cypress": "^5.0.8",
    "babel-plugin-istanbul": "^6.0.0",
    "nyc": "^15.1.0"
  },"nyc": {
    "extends": "./.nycrc.json",
    "report-dir": "cypress-coverage",
    "reporter": [
      "json",
      "lcov"
    ]
  }

.babelrc:

{
"presets": [
    "next/babel"
  ],
  "plugins": ["istanbul"]
}

.nycrc.json:

{
    "extension": [".js", ".jsx", ".ts", ".tsx"],
    "extends": "@istanbuljs/nyc-config-typescript",
    "include": ["src/**/*"],
    "all": true,
    "sourceMap": true,
    "instrument": true
  } 

cypress/support/index.js:

import '@cypress/code-coverage/support';

cypress/plugins/index.ts:

import browserify from '@cypress/browserify-preprocessor';

const pluginConfig: Cypress.PluginConfig = (on, config) => {
  on('task', {
    isFileExist
  })
  const options = browserify.defaultOptions;
  options.browserifyOptions.transform[1][1].babelrc = true;
  options.typescript = require.resolve('typescript');

  require('@cypress/code-coverage/task')(on, config);
  on('file:preprocessor', browserify(options));

  return config;
};
module.exports = pluginConfig;

Error message from automated build:

Cannot find coverage file /tmp/build/515f5098/project_root_folder/.nyc_output/out.json
Skipping coverage report

Muthu2190 avatar Nov 23 '21 05:11 Muthu2190

Any update or information on this?

thednp avatar Apr 23 '22 19:04 thednp

is there any update? I came across same issue

shirleyzhoufc avatar Sep 07 '22 05:09 shirleyzhoufc

Same issue here. Locally it's working fine but on the gitlab-ci pipeline some tests are not passing:

...
    Test suite foo
      ✓ should ...
      ✓ should foo1
      ✓ should foo2
      ✓ should foo3
      1) "before each" hook for "should foo4"
Cannot find coverage file /appl/grp/gitlab-runner/builds/frhxYBZs/0/myapp/.nyc_output/out.json
Skipping coverage report
  10 passing (25s)
...

Any idea?

arberosmani avatar Oct 28 '22 13:10 arberosmani

@arberosmani you can have a look at my repo relatively recent update. The github cli doesn't fail.

Note: the repo is typescript!

thednp avatar Oct 28 '22 15:10 thednp

no update on this issue?

wuwei3 avatar May 29 '23 06:05 wuwei3