mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
We forked test assertions in places in the early days of merging Turbopack. Now that we more closely align, a bunch of these had the exact same assertions. Fold them into one.
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import {
|
|
getRedboxDescription,
|
|
getRedboxSource,
|
|
waitForRedbox,
|
|
} from 'next-test-utils'
|
|
|
|
describe('Invalid Image Import (dev)', () => {
|
|
const { next, isTurbopack } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
it('should show error', async () => {
|
|
const browser = await next.browser('/')
|
|
await waitForRedbox(browser)
|
|
const description = await getRedboxDescription(browser)
|
|
if (isTurbopack) {
|
|
expect(description).toContain('Processing image failed')
|
|
} else {
|
|
expect(description).toContain(
|
|
'Image import "../public/invalid.svg" is not a valid image file. The image may be corrupted or an unsupported format.'
|
|
)
|
|
}
|
|
const source = await getRedboxSource(browser)
|
|
if (isTurbopack) {
|
|
expect(source).toContain('Processing image failed')
|
|
expect(source).toContain(
|
|
'Failed to parse svg source code for image dimensions'
|
|
)
|
|
expect(source).toContain(
|
|
'Source code does not contain a <svg> root element'
|
|
)
|
|
} else {
|
|
expect(source).toContain('./pages/index.js')
|
|
expect(source).toContain(
|
|
'Image import "../public/invalid.svg" is not a valid image file. The image may be corrupted or an unsupported format.'
|
|
)
|
|
}
|
|
})
|
|
})
|