angular / angular/components

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

Aperta
#22,428 4 commenti 2 reazioni 0 assegnatari Vedi su GitHub
area: material/autocomplete area: material/testing needs investigation P3
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dal repository di riproduzione collegato ed esegui `npm run test`, quindi riproduci la differenza tra una finestra di Chrome in background e in primo piano. Esamina il risultato di `autocompleteHarness.getOptions()`, che dovrebbe contenere 3 opzioni in entrambi i casi. Il lavoro è completato quando il test unitario passa in modo consistente sia con la finestra Jasmine Chrome visibile sia in background.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.