[ViteJS] Empty coverage for all files not covered by tests

Đang mở
#539 27 bình luận 2 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
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, typescript, vite
Lĩnh vực
frontend, testing-qa

Hướng nghiên cứu

Bắt đầu với cấu hình dev-server của Cypress, vite.config.js và thiết lập support và task của @cypress/code-coverage được nêu trong báo cáo. Tái hiện trường hợp cài đặt all của NYC với vite-plugin-istanbul, sau đó theo dõi cách các tệp rỗng được chuyển thành báo cáo coverage. Hoàn tất nghĩa là các tệp chưa được kiểm thử vẫn giữ dữ liệu dòng đã instrument và được đưa vào phép tính coverage cuối cùng.

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

Mô tả

Versions

  • What is this plugin's version? 3.9.12
  • What is Cypress version? 9.1.0
  • What is your operating system? MacOS
  • How do you instrument your application? Instanbul
  • Is there .nyc_output folder? Yes, not empty
  • Do you have any custom NYC settings? Yes, all
  • Do you run Cypress tests in a Docker container? No

Describe the bug
Despite using the all setting of NYC, it seems like only files touched by tests have their line numbers included in the report.
The other files are present but show 0 lines thus are ignored in the final computation of the code coverage.
Using the debug flag, I see them added:

  code-coverage adding empty coverage for file /Users/Sytten/Projects/*****/src/main.ts +0ms
  code-coverage adding empty coverage for file /Users/Sytten/Projects/*****/src/composables/index.ts +0ms
  code-coverage adding empty coverage for file /Users/Sytten/Projects/*****/src/composables/useId.ts +0ms
  code-coverage adding empty coverage for file /Users/Sytten/Projects/*****src/composables/useName.ts +0ms

But I would expect them to get line numbers at some point. But they only get:

TN:
SF:src/main.ts
FNF:0
FNH:0
LF:0
LH:0
BRF:0
BRH:0
end_of_record

I use ViteJS and my plugins looks like:

const path = require("path");
const { startDevServer } = require("@cypress/vite-dev-server");
const codeCoverageTask = require("@cypress/code-coverage/task");
const istanbul = require("vite-plugin-istanbul");

module.exports = (on, config) => {
  on("dev-server:start", (options) =>
    startDevServer({
      options,
      viteConfig: {
        logLevel: "warn",
        configFile: path.resolve(__dirname, "..", "..", "vite.config.js"),
        plugins: [istanbul({})],
      },
    })
  );

  codeCoverageTask(on, config);
  return config;
};

Support contains:

// Import commands.js using ES2015 syntax:
import "./commands";

// Alternatively you can use CommonJS syntax:
// require('./commands')

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

The coverage for files under test works fine.

Link to the repo
This is not an open-source project, but happy to provide a reproduction if that can help debug it.

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.