nodejs / nodejs/node

Unexpected behaviour of `beforeEach` outside of suite without test isolation

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

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

test_runner test_runner-agenda
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.4k
Merge trung bình
4 ngày 3 giờ
Pull request đã merge (30 ngày)
272

Mô tả

What is the problem this feature will solve?

In test runners such as jest or vitest, callbacks passed to the methods before, after, beforeEach or afterEach not wrapped in any describe, are called only when tests in their module are about to start or end. That's also the current behaviour when --test-isolation=process. Unfortunately, when the --test-isolation is none, the callbacks we pass to those 4 functions are added as global callbacks and they start to be called before/after each test in any file.

That's unexpected behaviour and it makes it more difficult to migrate from other test runners to node test runner or from the default --test-isolation=process.

What is the feature you are proposing to solve the problem?

Each module should be wrapped in a suite by default, so the callbacks don't leak to the other test modules. The only exception should be callbacks that we pass to those 4 methods in the global setup file(or its imports I guess).

Hướng dẫn đóng góp

Mở 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.

Hướng nghiên cứu

Bắt đầu bằng cách theo dõi cách trình chạy test của Node.js xử lý các callback before, after, beforeEach và afterEach khi dùng --test-isolation=process và --test-isolation=none. Kiểm tra hành vi hiện có giữa các module test riêng biệt, bao gồm global setup và các import của nó. Công việc được hoàn tất khi các callback ở cấp module không còn chạy cho các test trong module khác, trong khi các callback của global setup vẫn giữ đúng phạm vi dự kiến.

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

Đánh giá

Công nghệ
javascript
Lĩnh vực
testing-qa
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

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.