Skip to content

Instantly share code, notes, and snippets.

@devotdev
Created December 5, 2024 15:00
Show Gist options
  • Save devotdev/41b1502656435a64c0eadd6461748bf0 to your computer and use it in GitHub Desktop.
Save devotdev/41b1502656435a64c0eadd6461748bf0 to your computer and use it in GitHub Desktop.
Using done callback for complex async code
it('fetches data using done callback', (done) => {
const data = { id: 1, name: 'John Doe' };
axios.get.mockResolvedValue({ data });
fetchData('https://api.example.com/user/1').then(result => {
expect(result).toEqual(data);
done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment