bug(MatSnackBarHarness): Testing a snack bar with a duration
- Vorherrschende Sprache
- TypeScript
- Sterne
- 25k
- Forks
- 6.8k
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 91
Beschreibung
#### 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.
Beitragsleitfaden
Rechercherichtung
Beginne mit der verknüpften StackBlitz-Reproduktion, insbesondere mit src/app/example-test.spec.ts, und verfolge MatSnackBarHarness.getMessage(), wenn die Snack Bar eine Dauer hat. Vergleiche dies mit einer Snack Bar ohne Dauer. Fertig ist die Aufgabe, wenn der Harness die Nachricht abruft, anstatt auf die Ausblendung zu warten und mit "Failed to find element" fehlzuschlagen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- angular, typescript
- Bereich
- testing
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100