forked from vercel/next.js
/
index.test.js
54 lines (46 loc) · 1.33 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
/* eslint-env jest */
/* global jasmine */
import fs from 'fs-extra'
import { nextBuild, nextExport } from 'next-test-utils'
import { join } from 'path'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2
const appDir = join(__dirname, '..')
const nextConfig = join(appDir, 'next.config.js')
const runTests = () => {
it('should build successfully', async () => {
const { stdout, code } = await nextBuild(appDir, [], { stdout: true })
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})
it('should show error for GSSP during export', async () => {
const { stderr, code } = await nextExport(
appDir,
{ outdir: join(appDir, 'out') },
{ stderr: true }
)
expect(code).toBe(1)
expect(stderr).toMatch(
/pages with `getServerSideProps` can not be exported. See more info here: https/
)
})
}
describe('getServerSideProps', () => {
describe('serverless mode', () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
await fs.writeFile(
nextConfig,
`module.exports = { target: 'experimental-serverless-trace' }`,
'utf8'
)
})
runTests()
})
describe('production mode', () => {
beforeAll(async () => {
await fs.remove(nextConfig)
await fs.remove(join(appDir, '.next'))
})
runTests()
})
})