-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] add
withConsoleThrows
mocha-wrap
plugin
- Loading branch information
Showing
1 changed file
with
17 additions
and
0 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
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); | ||
}, | ||
})); | ||
}); |