angular / angular/components

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

Ouverte
#19,290 10 commentaires 2 réactions 0 personnes assignées Voir sur GitHub
area: material/snack-bar P3
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par la reproduction StackBlitz liée, en particulier src/app/example-test.spec.ts, et suivez MatSnackBarHarness.getMessage() lorsque la snack bar a une durée. Comparez-la à une snack bar sans durée. Le travail est terminé lorsque le harness récupère le message au lieu d’attendre la fermeture et d’échouer avec "Failed to find element".

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
testing
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.