-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add integration tests for cancel functionality
- Loading branch information
1 parent
c0c739c
commit 649297a
Showing
6 changed files
with
203 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
import {cleanup} from '@testing-library/react' | ||
import 'intersection-observer' | ||
import MutationObserver from 'mutation-observer' | ||
import fetchMock from 'jest-fetch-mock' | ||
|
||
// global vars | ||
process.env.API_PREFIX = 'http://example.com/' | ||
|
||
declare global { | ||
interface Window { | ||
flushAllPromises: () => Promise<any> | ||
MutationObserver: MutationObserver | ||
} | ||
} | ||
|
||
// Adds MutationObserver as a polyfill for testing | ||
window.MutationObserver = MutationObserver | ||
|
||
window.flushAllPromises = async () => { | ||
return new Promise(resolve => setImmediate(resolve)) | ||
} | ||
|
||
// mocks and stuff | ||
fetchMock.enableMocks() | ||
jest.mock('honeybadger-js', () => () => null) | ||
|
||
process.env.API_PREFIX = '/' | ||
// cleans up state between @testing-library/react tests | ||
afterEach(() => { | ||
cleanup() | ||
fetchMock.resetMocks() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters