In Svelte onMount I'm doing following logic.
onMount(async () => {
projectId = await new URLSearchParams(window.location.search).get('p');
jobId = await new URLSearchParams(window.location.search).get('j');
getJobs();
});
Then I have following test
test('will call getJobs endpoint on page load', () => {
render(SingleJobView);
setTimeout(() => {
expect(getJobs).toHaveBeenCalled();
}, 1000);
});
The problem is, that unit test will not pass without setTimeout
. How can I test the projectId, jobId
as mocked url parameters and getJobs
endpoint call without setTimeout
?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4