web-ui tests: enable Testing Library cleanup for every test file

Đang mở
#627 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
50/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, typescript
Lĩnh vực
testing

Hướng nghiên cứu

Start by reading web-ui/vitest.config.ts and web-ui/src/test/setup.ts, then inspect how test files currently call cleanup(). Decide whether to register cleanup in setup or enable globals, and check for tests that rely on state surviving between tests. Done means rendered components are cleaned up after each test, redundant per-file cleanup is removed where safe, and the test suite passes.

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

Mô tả

enhancement

Background

web-ui/vitest.config.ts does not enable globals, so afterEach is not global and @testing-library/react never registers its automatic cleanup. Components and hooks rendered in a test stay mounted until the file ends unless the file calls cleanup() itself.

#615 fixed one consequence: useStyleWorkspace.test.ts left three hooks mounted, and a hashchange in the last afterEach re-rendered them after jsdom was torn down. CI then reported ReferenceError: window is not defined and exited 1 although every test passed (seen on #609, #610 and main at c44d3479). Many other files already call cleanup() by hand; any file that does not has the same gap.

Proposal

Add afterEach(cleanup) to web-ui/src/test/setup.ts (or enable globals: true), then drop the per-file cleanup() calls that become redundant.

Open points

  • setup.ts hook vs. globals: true (the latter also changes how describe/it/expect resolve).
  • Tests that rely on state surviving across tests in the same file will need checking.
Ngôn ngữ chính
Python
Star
136
Fork
13
Merge trung bình
7 giờ 36 phút
Pull request đã merge (30 ngày)
175

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

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 aws-samples/sample-spec-driven-presentation-maker

Tất cả issue của aws-samples/sample-spec-driven-presentation-maker

Issue tương tự

Thêm issue về Python

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.