forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.webpack.js
49 lines (38 loc) · 1.06 KB
/
tests.webpack.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* eslint-env mocha */
import 'babel-polyfill'
import expect from 'expect'
import { _resetWarned } from './modules/routerWarning'
beforeEach(() => {
/* eslint-disable no-console */
expect.spyOn(console, 'error').andCall(msg => {
let expected = false
console.error.expected.forEach(about => {
if (msg.indexOf(about) !== -1) {
console.error.warned[about] = true
expected = true
}
})
if (expected)
return
console.error.threw = true
throw new Error(msg)
})
console.error.expected = []
console.error.warned = Object.create(null)
console.error.threw = false
/* eslint-enable no-console */
})
afterEach(() => {
/* eslint-disable no-console */
const { threw, expected, warned } = console.error
console.error.restore()
if (!threw) {
expected.forEach(about => {
expect(warned[about]).toExist(`Missing expected warning: ${about}`)
})
}
/* eslint-enable no-console */
_resetWarned()
})
const context = require.context('./modules', true, /-test\.js$/)
context.keys().forEach(context)