**index.test.js
fireEvent.click(refreshButton);
expect(dataFetcher).toBeCalledTimes(2);
await waitFor(() => {
const votesAfterRefresh = screen.getByText(/12345/i);
expect(votesAfterRefresh).toBeInTheDocument();
});
});
Terminal – npm test
I couldn’t find the right is
expect(dataFetcher).toBeCalledTimes(2)
expect(jest.fn()).toBeCalledTimes(expected)
Expected number of calls: 2
Received number of calls: 1
78 | fireEvent.click(refreshButton);
79 |
> 80 | expect(dataFetcher).toBeCalledTimes(2);
| ^
81 | await waitFor(() => {
82 | const votesAfterRefresh = screen.getByText(/12345/i);
83 | expect(votesAfterRefresh).toBeInTheDocument();
at Object.<anonymous> (src/components/Scoreboard.test.js:80:23)
Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 9 passed, 10 total
Snapshots: 0 total
Time: 1.565 s
Ran all test suites.**