forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
56 lines (48 loc) · 1.27 KB
/
index.test.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
50
51
52
53
54
55
56
/* eslint-env jest */
import {
check,
findPort,
getRedboxSource,
hasRedbox,
killApp,
launchApp,
} from 'next-test-utils'
import webdriver from 'next-webdriver'
import { join } from 'path'
const appDir = join(__dirname, '../')
describe('devtool set in development mode in next config', () => {
it('should warn and revert when a devtool is set in development mode', async () => {
let stderr = ''
const appPort = await findPort()
const app = await launchApp(appDir, appPort, {
env: { __NEXT_TEST_WITH_DEVTOOL: true },
onStderr(msg) {
stderr += msg || ''
},
})
const found = await check(
() => stderr,
/Reverting webpack devtool to /,
false
)
const browser = await webdriver(appPort, '/')
expect(await hasRedbox(browser)).toBe(true)
if (process.platform === 'win32') {
// TODO: add win32 snapshot
} else {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"pages/index.js (5:10) @ eval
3 | export default function Index(props) {
4 | useEffect(() => {
> 5 | throw new Error('this should render')
| ^
6 | }, [])
7 | return <div>Index Page</div>
8 | }"
`)
}
await browser.close()
await killApp(app)
expect(found).toBeTruthy()
})
})