rsnext/test/e2e/next-font/font-loader-in-document-error.test.ts
Hannes Bornö be7b10dee5
Recover from font loader error in dev (#41251)
Check that the module has assets. This might not always be the case in
app dev if there was an error. Test added to make sure it recovers
correctly.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-10-08 01:53:24 +02:00

39 lines
1.1 KiB
TypeScript

import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { getRedboxSource, hasRedbox } from 'next-test-utils'
import webdriver from 'next-webdriver'
import { join } from 'path'
describe('font-loader-in-document-error', () => {
const isDev = (global as any).isNextDev
let next: NextInstance
if (!isDev) {
it('should only run on next dev', () => {})
return
}
beforeAll(async () => {
next = await createNext({
files: {
pages: new FileRef(join(__dirname, 'font-loader-in-document/pages')),
'next.config.js': new FileRef(
join(__dirname, 'font-loader-in-document/next.config.js')
),
},
dependencies: {
'@next/font': 'canary',
},
})
})
afterAll(() => next.destroy())
test('font loader inside _document', async () => {
const browser = await webdriver(next.appPort, '/')
expect(await hasRedbox(browser, true)).toBeTrue()
expect(await getRedboxSource(browser)).toMatch(/Font loaders/)
expect(await getRedboxSource(browser)).toInclude(
'Font loaders cannot be used within pages/_document.js'
)
})
})