out.json file generated without code informations

オープン
#498 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
angular, cypress, node.js, typescript
領域
testing-qa

調査の方向性

cypress/support/index.js、cypress/plugins/index.js、.babelrc、cypress.json、および package.json の scripts と nyc の設定から始めます。Cypress の警告を再現し、window.coverage が存在するか、また .nyc_output/out.json に mappings と counters が書き込まれるかを確認します。生成された coverage データに空のマップではなくコード情報が含まれていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
  }
}

主要言語
TypeScript
スター
440
フォーク
114
平均マージ
42分
マージ済み PR(30日)
19

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cypress-io/code-coverage のほかの issue

cypress-io/code-coverage の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。