-
Notifications
You must be signed in to change notification settings - Fork 28.1k
/
Copy pathindex.test.ts
101 lines (93 loc) · 2.55 KB
/
index.test.ts
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import {
check,
findPort,
killApp,
launchApp,
renderViaHTTP,
} from 'next-test-utils'
import fs from 'fs-extra'
import { join } from 'path'
describe('turbopack unsupported features log', () => {
if (process.env.TURBOPACK) {
const appDir = join(__dirname, 'app')
it('should not warn by default', async () => {
let output = ''
const appPort = await findPort()
const app = await launchApp(appDir, appPort, {
onStdout(msg) {
output += msg
},
onStderr(msg) {
output += msg
},
})
try {
expect(await renderViaHTTP(appPort, '/')).toContain('hello world')
expect(output).toContain('(turbo)')
expect(output).not.toContain(
'You are using configuration and/or tools that are not yet'
)
} finally {
await killApp(app).catch(() => {})
}
})
const nextConfigPath = join(appDir, 'next.config.js')
it('should not warn with empty next.config.js', async () => {
let output = ''
await fs.writeFile(nextConfigPath, `module.exports = {}`)
const appPort = await findPort()
const app = await launchApp(appDir, appPort, {
onStdout(msg) {
output += msg
},
onStderr(msg) {
output += msg
},
})
try {
expect(output).toContain('(turbo)')
expect(output).not.toContain(
'You are using configuration and/or tools that are not yet'
)
expect(await renderViaHTTP(appPort, '/')).toContain('hello world')
} finally {
await killApp(app).catch(() => {})
await fs.remove(nextConfigPath)
}
})
it('should warn with next.config.js with unsupported field', async () => {
let output = ''
await fs.writeFile(
nextConfigPath,
`module.exports = {
experimental: {
urlImports: true
}
}`
)
const appPort = await findPort()
const app = await launchApp(appDir, appPort, {
onStdout(msg) {
output += msg
},
onStderr(msg) {
output += msg
},
})
try {
await check(() => {
expect(output).toContain('(turbo)')
expect(output).toContain(
'You are using configuration and/or tools that are not yet'
)
return 'success'
}, /success/)
} finally {
await killApp(app).catch(() => {})
await fs.remove(nextConfigPath)
}
})
} else {
it.skip('turbopack only', () => {})
}
})