out.json file generated without code informations

Đang mở
#498 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
angular, cypress, node.js, typescript
Lĩnh vực
testing-qa

Hướng nghiên cứu

Bắt đầu với cypress/support/index.js, cypress/plugins/index.js, .babelrc, cypress.json, cùng các script trong package.json và cấu hình nyc. Tái hiện cảnh báo của Cypress và kiểm tra xem window.coverage có tồn tại hay không, cũng như .nyc_output/out.json có nhận được mappings và counters hay không. Hoàn thành khi dữ liệu coverage được tạo ra chứa thông tin mã thay vì các map rỗng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
440
Fork
114
Merge trung bình
42 phút
Pull request đã merge (30 ngày)
19

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cypress-io/code-coverage

Tất cả issue của cypress-io/code-coverage

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.