Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update invalid-image-import test for Turbopack #61079

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,33 @@ const appDir = join(__dirname, '../')
let appPort: number
let app
let stderr = ''
const msg =
'Error: Image import "../public/invalid.svg" is not a valid image file. The image may be corrupted or an unsupported format.'

function runTests({ isDev }) {
it('should show error', async () => {
if (isDev) {
const browser = await webdriver(appPort, '/')
expect(await hasRedbox(browser)).toBe(true)
expect(await getRedboxHeader(browser)).toBe('Failed to compile')
expect(await getRedboxSource(browser)).toBe(`./pages/index.js:3\n${msg}`)
expect(stripAnsi(stderr)).toContain(msg)
const source = await getRedboxSource(browser)
if (process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(`
"./test/integration/next-image-new/invalid-image-import/public/invalid.svg
Processing image failed
Failed to parse svg source code for image dimensions

Caused by:
- Source code does not contain a <svg> root element"
timneutkens marked this conversation as resolved.
Show resolved Hide resolved
`)
} else {
expect(source).toMatchInlineSnapshot(`
"./pages/index.js:3
Error: Image import "../public/invalid.svg" is not a valid image file. The image may be corrupted or an unsupported format."
`)
}
} else {
expect(stripAnsi(stderr)).toContain(msg)
expect(stripAnsi(stderr)).toContain(
'Error: Image import "../public/invalid.svg" is not a valid image file. The image may be corrupted or an unsupported format.'
)
}
})
}
Expand Down
Loading