next.js/test/e2e/app-dir/metadata-invalid-image-file/metadata-invalid-image-file.test.ts
metadata-invalid-image-file.test.ts48 lines1.3 KB
import { nextTestSetup } from 'e2e-utils'

describe('metadata-invalid-image-file', () => {
  const { next, isTurbopack, isNextDev, skipped, isRspack } = nextTestSetup({
    files: __dirname,
    skipDeployment: true,
    skipStart: true,
  })

  if (skipped) return

  it('should error on invalid metadata image file', async () => {
    // In dev, it needs to render the page first
    if (isNextDev) {
      await next.start()
      await next.fetch('/')
    } else {
      await next.build()
    }

    if (isTurbopack) {
      // In turbopack the image decoding error is displayed in multiple lines
      expect(next.cliOutput).toContain('app/favicon.ico')
      expect(next.cliOutput).toContain('Processing image failed')
      expect(next.cliOutput).toContain('unable to decode image data')
    } else {
      expect(next.cliOutput).toContain(
        'Error: Process image "/favicon.ico" failed:'
      )
    }

    if (!isNextDev) {
      // `next build` should fail
      if (isTurbopack) {
        expect(next.cliOutput).toContain('Build error occurred')
      } else if (isRspack) {
        expect(next.cliOutput).toContain(
          'Build failed because of Rspack errors'
        )
      } else {
        expect(next.cliOutput).toContain(
          'Build failed because of webpack errors'
        )
      }
    }
  })
})
Quest for Codev2.0.0
/
SIGN IN