angular / angular/components

bug(Autocomplete): unit test using MatAutocompleteHarness fails when karma browser is in the foreground

Ouverte
#22,428 4 commentaires 2 réactions 0 personnes assignées Voir sur GitHub
area: material/autocomplete area: material/testing needs investigation P3
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

#### Reproduction

* Clone repo: https://github.com/DmitryEfimenko/mat-autocomplete-harness-issue
* install deps

Steps to reproduce:
1. In the console: `npm run test`
1. Make sure NOT to bring the opened Chrome window showing Jasmine tests into the visibility
If it opens in front, quickly click on some other window to bring the Chrome window to the background
1. Observe: test succeeds
1. make a small change in test (change spec name) to trigger test re-run
1. Observe: test still succeeds
1. Bring the Chrome window showing Jasmine tests into the visibility
1. Observe: test fail

Recording:
https://user-images.githubusercontent.com/2098175/113951456-76f5b680-97c8-11eb-9893-5cca66ac1a8c.mp4

#### Expected Behavior

Unit test should pass.
Specifically, `autocompleteHarness.getOptions()` should return 3 options instead of 0

#### Actual Behavior

Unit test only passes while the Jasmine Chrome window is in the background

#### Environment

- Angular: 11.2.8
- CDK/Material: 11.2.7
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Tested on:
- Windows
- Mac

#### Notes

I have created a StackBlitz repository with basically the same code, but can't reproduce the issue there:
https://stackblitz.com/edit/harness-issue-2m77t5?file=src/app/autocomplete-harness-example.spec.ts

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par le dépôt de reproduction lié et exécutez `npm run test`, puis reproduisez la différence entre une fenêtre Chrome en arrière-plan et au premier plan. Examinez le résultat de `autocompleteHarness.getOptions()`, qui devrait contenir 3 options dans les deux cas. Le travail est terminé lorsque le test unitaire réussit systématiquement, que la fenêtre Jasmine Chrome soit visible ou en arrière-plan.

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

Évaluation

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

Recevez les nouvelles issues par e-mail

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