forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-errors.test.ts
More file actions
76 lines (61 loc) · 2.11 KB
/
build-errors.test.ts
File metadata and controls
76 lines (61 loc) · 2.11 KB
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
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { join } from 'path'
import webdriver from 'next-webdriver'
import { getRedboxSource, hasRedbox } from 'next-test-utils'
// TODO: The error overlay is not closed when restoring the working code.
describe.skip('next/font build-errors', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: new FileRef(join(__dirname, 'build-errors')),
})
})
afterAll(() => next.destroy())
it('should show a next/font error when input is wrong', async () => {
const browser = await webdriver(next.url, '/')
const content = await next.readFile('app/page.js')
await next.patchFile(
'app/page.js',
`
import localFont from 'next/font/local'
const font = localFont()
export default function Page() {
return <p className={font.className}>Hello world!</p>
}
`
)
expect(await hasRedbox(browser)).toBeTrue()
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"app/page.js
\`next/font\` error:
Missing required \`src\` property"
`)
await next.patchFile('app/page.js', content)
expect(await hasRedbox(browser)).toBeFalse()
})
it("should show a module not found error if local font file can' be resolved", async () => {
const browser = await webdriver(next.url, '/')
const content = await next.readFile('app/page.js')
await next.patchFile(
'app/page.js',
`
import localFont from 'next/font/local'
const font = localFont({ src: './boom.woff2'})
export default function Page() {
return <p className={font.className}>Hello world!</p>
}
`
)
expect(await hasRedbox(browser)).toBeTrue()
const sourceLines = (await getRedboxSource(browser)).split('\n')
// Should display the file name correctly
expect(sourceLines[0]).toEqual('app/page.js')
// Should be module not found error
expect(sourceLines[1]).toEqual(
"Module not found: Can't resolve './boom.woff2'"
)
await next.patchFile('app/page.js', content)
expect(await hasRedbox(browser)).toBeFalse()
})
})