Skip to content

Commit

Permalink
Use withConsoleThrows instead of spying on console.error
Browse files Browse the repository at this point in the history
  • Loading branch information
suchipi authored and ljharb committed Aug 8, 2018
1 parent fec6990 commit 965b785
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,13 @@ describeWithDOM('mount', () => {
describeIf(is('>= 16.3'), 'uses the isValidElementType from the Adapter to validate the prop type of Component', () => {
const Foo = () => null;
const Bar = () => null;

beforeEach(() => {
sinon.spy(console, 'error');
});

afterEach(() => {
// eslint-disable-next-line no-console
console.error.restore();
});

wrap()
.withConsoleThrows()
.withOverride(() => getAdapter(), 'isValidElementType', () => val => val === Foo)
.it('with isValidElementType defined on the Adapter', () => {
mount(<Bar />);
// eslint-disable-next-line no-console
expect(console.error.getCall(0).args).to.deep.equal([
'Warning: Failed prop type: Component must be a valid element type!\n in WrapperComponent',
]);
expect(() => {
mount(<Bar />);
}).to.throw('Warning: Failed prop type: Component must be a valid element type!\n in WrapperComponent');
});
});
});
Expand Down

0 comments on commit 965b785

Please sign in to comment.