angular / angular/components

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

オープン
#19,290 コメント 10 件 リアクション 2 件 担当者 0 名 GitHub で見る
area: material/snack-bar P3
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

リンクされている StackBlitz の再現コード、特に src/app/example-test.spec.ts から始め、snack bar に duration がある場合の MatSnackBarHarness.getMessage() を追跡します。duration がない snack bar と比較します。harness が閉じられるのを待って "Failed to find element" で失敗するのではなく、メッセージを取得できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
testing
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。