angular / angular/components

bug(MatSnackBarHarness): Testing a snack bar with a duration

Đang mở
#19,290 10 bình luận 2 reaction 0 người được giao Xem trên GitHub
area: material/snack-bar P3
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

#### Reproduction

https://stackblitz.com/edit/components-issue-v9512z?file=src%2Fapp%2Fexample-test.spec.ts

Steps to reproduce:
1. Try to e.g. `await harness.getMessage()` a snack bar that was opened with a `duration`. You can see this simply by following the link above, which will run that automatically.

#### Expected Behavior

The harness returns the message in the snack bar.

#### Actual Behavior

The test hangs for the duration that the snack bar is open, then fails with "Failed to find element".

#### Environment

- Angular: 9.1.5
- CDK/Material: 9.2.2
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows

#### Commentary

Using the same test code, I can test a snack bar that was opened without a duration. But if my production code _does_ use a duration it does not appear possible to test it with the harness. Am I missing something? I assume assigning a duration is a common use-case.

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

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với bản tái hiện StackBlitz được liên kết, đặc biệt là src/app/example-test.spec.ts, và theo dõi MatSnackBarHarness.getMessage() khi snack bar có thời lượng. So sánh với một snack bar không có thời lượng. Hoàn tất khi harness lấy được thông báo thay vì chờ bị loại bỏ rồi thất bại với "Failed to find element".

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

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
testing
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/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.