Skip to content

Commit

Permalink
[Tests] add withConsoleThrows mocha-wrap plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Aug 16, 2018
1 parent ea9906f commit be1f272
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/enzyme-test-suite/test/_helpers/setupAdapters.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
const Enzyme = require('enzyme');
const wrap = require('mocha-wrap');

const Adapter = require('./adapter');

Enzyme.configure({ adapter: new Adapter() });

const origWarn = console.warn;
const origError = console.error;
wrap.register(function withConsoleThrows() {
return this.withOverrides(() => console, () => ({
error(msg) {
origError.apply(console, arguments); // eslint-disable-line prefer-rest-params
throw new EvalError(msg);
},
warn(msg) {
origWarn.apply(console, arguments); // eslint-disable-line prefer-rest-params
throw new EvalError(msg);
},
}));
});

0 comments on commit be1f272

Please sign in to comment.