forked from vercel/next.js
/
index.test.js
57 lines (50 loc) · 1.14 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
57
/* eslint-env jest */
import { join } from 'path'
import webdriver from 'next-webdriver'
import {
findPort,
launchApp,
killApp,
nextStart,
nextBuild,
} from 'next-test-utils'
jest.setTimeout(1000 * 60 * 5)
let app
let appPort
const appDir = join(__dirname, '..')
const runTests = () => {
it('should not have hydration mis-match for hash link', async () => {
const browser = await webdriver(appPort, '/')
const browserLogs = await browser.log('browser')
let found = false
browserLogs.forEach((log) => {
if (
log.message.includes(
'Warning: Prop'
)
) {
found = true
}
})
expect(found).toEqual(false)
})
}
describe('Link with hash href', () => {
describe('development', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
})
describe('production', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
})
})