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

out.json file generated without code informations

Open cynarar opened this issue 4 years ago • 0 comments

Logs and screenshots

 code-coverage coverage has 0 record(s) +0ms
coverage has the following first paths

  code-coverage adding empty coverage for file /home/user/dev/workspace/project/src/main.ts +1ms
  code-coverage adding empty coverage for file /home/user/dev/workspace/project/src/polyfills.ts +0ms
  code-coverage adding empty coverage for file /home/user/dev/workspace/project/src/test.ts +0ms
  code-coverage adding empty coverage for file /home/user/dev/workspace/project/src/app/app-routing.module.ts +0ms
  code-coverage adding empty coverage for file /home/user/dev/workspace/project/src/app/app.component.ts +0ms
  code-coverage adding empty coverage for file /home/user/dev/workspace/project/src/app/app.module.ts +0ms
...
code-coverage includeAllFiles saving updated file /home/user/dev/workspace/project/.nyc_output/out.json +0ms
 code-coverage there are 113 keys in the file +0ms
code-coverage calling NYC reporter with options { 'report-dir': '/home/user/dev/workspace/project/cypress-coverage', reporter: [ 'json', 'lcov' ], extension: [ '.js', '.jsx', '.ts', '.tsx' ], excludeAfterRemap: false, extends: '@istanbuljs/nyc-config-typescript', include: [ 'src/**/*.ts' ], exclude: [ '**/*.d.ts', 'coverage/**', 'packages/*/test/**', 'test/**', 'test{,-*}.ts', '**/*{.,-}{test,spec}.ts', '**/__tests__/**', '**/node_modules/**', 'support-utils.js', 'task-utils.js' ], all: true, 'check-coverage': true, 'temp-directory': '.nyc_output', sourceMap: true, instrument: true, 'temp-dir': '/home/user/dev/workspace/project/.nyc_output', tempDir: '/home/user/dev/workspace/project/.nyc_output', reportDir: '/home/user/dev/workspace/project/cypress-coverage' } +20ms
  code-coverage current working directory is /home/user/dev/workspace/project +0ms

Versions

Ubuntu 18.04.5 LTS Node 14.15.4 NPM: 7.20.5 Angular: 12.0.1 eslint: 7.26.0

My package.json:

"scripts": {
...
"instrument": "npx nyc instrument --compact=false src",
"cypress:open": "ng serve cypress open",
...
},
"devDependencies": {
...
	"@babel/core": "^7.14.3",
	"@cypress/code-coverage": "^3.9.10",
	"@istanbuljs/nyc-config-typescript": "^1.0.1",
	"babel-plugin-istanbul": "^6.0.0",
	"cypress": "^7.7.0",
	"cypress-sonarqube-reporter": "^1.7.1",
	"nyc": "^15.1.0",
...
},
,
"nyc": {
	"extension": [
		".js",
		".jsx",
		".ts",
		".tsx"
	],
	"extends": "@istanbuljs/nyc-config-typescript",
	"include": [
		"src/**/*.ts"
	],
	"exclude": [
		"**/*.d.ts",
		"coverage/**",
		"packages/*/test/**",
		"test/**",
		"test{,-*}.ts",
		"**/*{.,-}{test,spec}.ts",
		"**/__tests__/**",
		"**/node_modules/**",
		"support-utils.js",
		"task-utils.js"
	],
	"all": true,
	"check-coverage": true,
	"temp-directory": ".nyc_output",
	"sourceMap": true,
	"instrument": true,
	"report-dir": "cypress-coverage",
	"reporter": [
		"json",
		"lcov"
	]
}

No, I couldn't see the window.__coverage__ object in the console, as you can see in the printscreen: https://pasteboard.co/5bqIcB10m5xC.png

All the files in out.json file are like this:

"/home/user/dev/workspace/project/src/main.ts": {
    "path": "/home/user/dev/workspace/project/src/main.ts",
    "statementMap": {},
    "fnMap": {},
    "branchMap": {},
    "s": {},
    "f": {},
    "b": {}
  },

I'm executing Cypress localy.

Describe the bug

Cypress shows the message:

⚠️ Could not find any coverage information in your application
            by looking at the window coverage object.
            Did you forget to instrument your application?
            See [code-coverage#instrument-your-application](https://github.com/cypress-io/code-coverage#instrument-your-application)
           `[@cypress/code-coverage]`

I followed all the steps of configuration in the site above. I searched for people that had similar issue, tried all sugestions, but I didn't have success. The report is generated normally.

Here is my configuration:

cypress/support/index.js:

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

cypress/plugins/index.js:

module.exports = (on, config) => {
	require('@cypress/code-coverage/task')(on, config);
	return config;
};

.babelrc:

{
	"plugins": ["istanbul"]
}

eslintrc.json:

....
"extends": [..., "next/babel"]

cypress.json:

{
  "integrationFolder": "cypress/integration",
  "supportFile": "cypress/support/index.js",
  "videosFolder": "cypress/videos",
  "screenshotsFolder": "cypress/screenshots",
  "pluginsFile": "cypress/plugins/index.js",
  "fixturesFolder": "cypress/fixtures",
  "baseUrl": "http://localhost:4200",
  "projectId": "XXXXX",
  "reporter": "cypress-sonarqube-reporter",
  "env": {
    "BABEL_ENV": "e2e"
  },
  "chromeWebSecurity": false,
  "reporterOptions": {
    "outputDir": "./sonar",
    "overwrite": true
  }
}

cynarar avatar Sep 10 '21 18:09 cynarar