File tree 1 file changed +37
-0
lines changed
projects/testing-library/tests/issues
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { Component } from '@angular/core' ;
2
+ import { throwError } from 'rxjs' ;
3
+ import { render , screen } from '@testing-library/angular' ;
4
+ import userEvent from '@testing-library/user-event' ;
5
+
6
+ @Component ( {
7
+ selector : 'app-test' ,
8
+ template : `<button (click)="onTest()">Test</button>` ,
9
+ styles : [ ] ,
10
+ } )
11
+ export class TestComponent {
12
+ onTest ( ) {
13
+ throwError ( ( ) => new Error ( 'myerror' ) ) . subscribe ( ) ;
14
+ }
15
+ }
16
+
17
+
18
+ describe ( 'TestComponent' , ( ) => {
19
+ beforeEach ( ( ) => {
20
+ jest . useFakeTimers ( ) ;
21
+ } ) ;
22
+
23
+ afterEach ( ( ) => {
24
+ jest . runAllTicks ( ) ;
25
+ jest . useRealTimers ( ) ;
26
+ } )
27
+
28
+ it ( 'does not fail' , async ( ) => {
29
+ await render ( TestComponent ) ;
30
+ await userEvent . click ( screen . getByText ( 'Test' ) ) ;
31
+ } ) ;
32
+
33
+ it ( 'fails because of the previous one' , async ( ) => {
34
+ await render ( TestComponent ) ;
35
+ await userEvent . click ( screen . getByText ( 'Test' ) ) ;
36
+ } ) ;
37
+ } ) ;
You can’t perform that action at this time.
0 commit comments