next.js/test/e2e/edge-runtime-deprecated/edge-runtime-deprecated.test.ts
edge-runtime-deprecated.test.ts38 lines1.0 KB
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'

const EXPECTED_WARNING =
  'The Edge Runtime is deprecated. You can use the "nodejs" runtime instead.'

describe('edge-runtime-deprecated', () => {
  const { next, isNextDev } = nextTestSetup({
    files: __dirname,
  })

  it('should warn about deprecated edge runtime', async () => {
    if (isNextDev) {
      // In dev mode, the warning fires when the edge route is first compiled.
      await next.fetch('/edge-route')
    }

    await retry(async () => {
      expect(next.cliOutput).toContain(EXPECTED_WARNING)
    })
  })

  it('should only warn once', async () => {
    if (isNextDev) {
      // Trigger compilation of the edge route again (already compiled, but
      // another request ensures no duplicate warnings).
      await next.fetch('/edge-route')
    }

    await retry(async () => {
      expect(next.cliOutput).toContain(EXPECTED_WARNING)
    })

    const occurrences = next.cliOutput.split(EXPECTED_WARNING).length - 1
    expect(occurrences).toBe(1)
  })
})
Quest for Codev2.0.0
/
SIGN IN