-
Notifications
You must be signed in to change notification settings - Fork 26k
/
index.test.js
64 lines (54 loc) · 1.76 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
58
59
60
61
62
63
64
/* eslint-env jest */
import { join } from 'path'
import {
findPort,
killApp,
launchApp,
nextBuild,
nextStart,
} from 'next-test-utils'
import webdriver from 'next-webdriver'
const appDir = join(__dirname, '../')
let appPort
let app
const runTests = () => {
describe('with middleware', () => {
it('should not trigger unncessary rerenders when middleware is used', async () => {
const browser = await webdriver(appPort, '/')
await new Promise((resolve) => setTimeout(resolve, 100))
expect(await browser.eval('window.__renders')).toEqual([undefined])
})
})
describe('with rewrites', () => {
// TODO: Figure out the `isReady` issue.
// it('should not trigger unncessary rerenders when rewrites or middleware are used', async () => {
// const browser = await webdriver(appPort, '/')
// await new Promise((resolve) => setTimeout(resolve, 100))
// expect(await browser.eval('window.__renders')).toEqual([undefined])
// })
// it('should rerender with the correct query parameter if present with rewrites', async () => {
// const browser = await webdriver(appPort, '/rewrite')
// await new Promise((resolve) => setTimeout(resolve, 100))
// expect(await browser.eval('window.__renders')).toEqual([undefined, 'bar'])
// })
})
}
describe('router rerender', () => {
describe('dev mode', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
})
describe('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
})
})