forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.webpack.js
40 lines (32 loc) · 897 Bytes
/
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
/* eslint-disable no-console */
/* eslint-env mocha */
import expect from 'expect'
import { _resetWarned } from './modules/routerWarning'
beforeEach(() => {
expect.spyOn(console, 'error').andCall(msg => {
for (const about of console.error.expected) {
if (msg.indexOf(about) !== -1) {
console.error.warned[about] = true
return
}
}
console.error.threw = true
throw new Error(msg)
})
console.error.expected = []
console.error.warned = Object.create(null)
console.error.threw = false
})
afterEach(() => {
if (!console.error.threw) {
console.error.expected.forEach(about => {
expect(console.error.warned[about]).toExist(
`Missing expected warning: ${about}`
)
})
}
console.error.restore()
_resetWarned()
})
const context = require.context('./modules', true, /-test\.js$/)
context.keys().forEach(context)