angular / angular/components

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

Aperta
#19,290 10 commenti 2 reazioni 0 assegnatari Vedi su GitHub
area: material/snack-bar P3
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

#### 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dalla riproduzione StackBlitz collegata, in particolare src/app/example-test.spec.ts, e segui MatSnackBarHarness.getMessage() quando la snack bar ha una durata. Confrontala con una snack bar senza durata. Il lavoro è completo quando l’harness recupera il messaggio invece di attendere la chiusura e fallire con "Failed to find element".

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
testing
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.