Skip to content

Commit

Permalink
Fix test intermittent
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatum committed Jan 21, 2019
1 parent 0a2c134 commit e1d4a7e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/test/unit/profile-conversion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('converting Google Chrome profile', function() {
it('successfully imports', async function() {
// Mock out image loading behavior as the screenshots rely on the Image loading
// behavior.
jest
const spy = jest
.spyOn(Image.prototype, 'addEventListener')
.mockImplementation((name: string, callback: Function) => {
if (name === 'load') {
Expand All @@ -51,5 +51,13 @@ describe('converting Google Chrome profile', function() {
throw new Error('Unable to parse the profile.');
}
expect(profile).toMatchSnapshot();

// This is really odd behavior, but this spy was showing up in stack traces in
// an intermittent test failure. Adding this manually mock restore made the error
// go away. Generally spies should be removed with automatically because of the
// "resetMocks" configuration option.
//
// See https://github.com/facebook/jest/issues/7654
spy.mockRestore();
});
});

0 comments on commit e1d4a7e

Please sign in to comment.