diff --git a/projects/testing-library/tests/issues/issue-386.spec.ts b/projects/testing-library/tests/issues/issue-386.spec.ts new file mode 100644 index 0000000..cccc850 --- /dev/null +++ b/projects/testing-library/tests/issues/issue-386.spec.ts @@ -0,0 +1,37 @@ +import {Component} from '@angular/core'; +import {throwError} from 'rxjs'; +import {render, screen} from '@testing-library/angular'; +import userEvent from '@testing-library/user-event'; + +@Component({ + selector: 'app-test', + template: ``, + styles: [], +}) +export class TestComponent { + onTest() { + throwError(() => new Error('myerror')).subscribe(); + } +} + + +describe('TestComponent', () => { + beforeEach(() => { + jest.useFakeTimers(); + }); + + afterEach(() => { + jest.runAllTicks(); + jest.useRealTimers(); + }) + + it('does not fail', async () => { + await render(TestComponent); + await userEvent.click(screen.getByText('Test')); + }); + + it('fails because of the previous one', async () => { + await render(TestComponent); + await userEvent.click(screen.getByText('Test')); + }); +});