-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from wheresrhys/play-nice-resetall
don't break when using jest.restoreAllMocks()
- Loading branch information
Showing
3 changed files
with
38 additions
and
9 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/*global jest */ | ||
jest.mock('node-fetch', () => require('../server').sandbox()); | ||
const fetch = require('node-fetch'); | ||
|
||
describe('regressions and strange cases', () => { | ||
it('works even when jest.resetAllMocks() is called', () => { | ||
jest.resetAllMocks(); | ||
fetch.mock('*', 200); | ||
fetch('http://example.com/path', 200); | ||
expect(fetch).toHaveFetched('http://example.com/path'); | ||
fetch.reset(); | ||
}); | ||
it('works even when jest.clearAllMocks() is called', () => { | ||
jest.clearAllMocks(); | ||
fetch.mock('*', 200); | ||
fetch('http://example.com/path', 200); | ||
expect(fetch).toHaveFetched('http://example.com/path'); | ||
fetch.reset(); | ||
}); | ||
}); |
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