/
index.test.js
51 lines (46 loc) · 1.42 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
/* eslint-env jest */
import path from 'path'
import {
nextBuild,
launchApp,
findPort,
killApp,
renderViaHTTP,
} from 'next-test-utils'
const appDir = path.join(__dirname, '..')
describe('Errors on conflict between public file and page file', () => {
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
it('Throws error during development', async () => {
const appPort = await findPort()
const app = await launchApp(appDir, appPort)
const conflicts = ['/another/conflict', '/hello']
for (const conflict of conflicts) {
const html = await renderViaHTTP(appPort, conflict)
expect(html).toMatch(
/A conflicting public file and page file was found for path/
)
}
await killApp(app)
})
}
)
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
it('Throws error during build', async () => {
const conflicts = ['/another/conflict', '/another', '/hello']
const results = await nextBuild(appDir, [], {
stdout: true,
stderr: true,
})
const output = results.stdout + results.stderr
expect(output).toMatch(/Conflicting public and page files were found/)
for (const conflict of conflicts) {
expect(output.indexOf(conflict) > 0).toBe(true)
}
})
}
)
})