Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from FormidableLabs/fix-test-console-mock
Browse files Browse the repository at this point in the history
Unmock console.error in a finally block
  • Loading branch information
aweary committed Nov 30, 2017
2 parents ecc99f8 + 7b1c156 commit 01e684f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions __tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ describe("react-progressive-image", () => {
/* eslint-disable no-console */
const _error = console.error;
console.error = jest.fn(() => {});
expect(() => {
mount(
<ProgressiveImage>
<h1>Uh oh!</h1>
</ProgressiveImage>
);
}).toThrow(`ProgressiveImage requires a function as its only child`);
console.error = _error;
try {
expect(() => {
mount(
<ProgressiveImage>
<h1>Uh oh!</h1>
</ProgressiveImage>
);
}).toThrow(`ProgressiveImage requires a function as its only child`);
} finally {
console.error = _error;
}
/* eslint-enable no-console */
});

Expand Down

0 comments on commit 01e684f

Please sign in to comment.