-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
@testing-library/reactversion: 10.3.0- Testing Framework and version: jest 26.0.1
- DOM Environment: jsdom 16.2.2
Relevant code or config:
https://codesandbox.io/s/great-dawn-s229i?file=/src/ServiceWorker.test.tsx
it('renders a toast onupdatefound triggering site reload on click', async () => {
const mockReload = jest.fn();
Object.defineProperty(window, 'location', {
value: {
reload: mockReload,
},
writable: true,
});
makeMockRegister({
addEventListener: makeMockAddEventListener(),
registration: jest.fn(),
shouldReject: false,
});
render(<ServiceWorker />);
const toast = await screen.findByRole('alert');
fireEvent.click(toast);
expect(mockReload).toHaveBeenCalledTimes(1);
});What you did:
Trying to write tests in the order the ServiceWorker executes.
What happened:
screen.findByRole('alert') fails because multiple elements with that query are in the DOM.
Reproduction:
https://codesandbox.io/s/great-dawn-s229i?file=/src/ServiceWorker.test.tsx
Problem description:
If I disable all other tests except that one, it works.
Changing the order of the tests works too; the test marked as problematic test currently is the 5th/last.
It works locally if its the 4th:

Sandbox does not like the 4th...

Adding cleanup or manually calling unmount() does not help at all.
mboettcher, bigfoot31, FernandoBasso, with-heart, coler-j and 24 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working

