/
index.test.js
57 lines (50 loc) · 1.34 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 {
renderViaHTTP,
launchApp,
nextBuild,
nextStart,
killApp,
findPort,
} from 'next-test-utils'
const appDir = join(__dirname, '..')
let appPort
let app
const runTests = () => {
it('should support optional chaining', async () => {
const html = await renderViaHTTP(appPort, '/optional-chaining')
expect(html).toMatch(/result1:.*?nothing/)
expect(html).toMatch(/result2:.*?something/)
})
it('should support nullish coalescing', async () => {
const html = await renderViaHTTP(appPort, '/nullish-coalescing')
expect(html).toMatch(/result1:.*?fallback/)
expect(html).not.toMatch(/result2:.*?fallback/)
})
}
describe('Optional chaining and nullish coalescing support', () => {
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
}
)
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
}
)
})