next.js/test/e2e/app-dir/dedupe-rsc-error-log/dedupe-rsc-error-log.test.ts
dedupe-rsc-error-log.test.ts39 lines1.1 KB
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'

async function expectContainOnce(next: any, search: string) {
  // Ensure the search string is found once
  await retry(() => {
    const parts = next.cliOutput.split(search)
    expect(parts.length).toBe(2)
  })
}

describe('dedupe-rsc-error-log', () => {
  const { next } = nextTestSetup({
    files: __dirname,
    // Runtime logs aren't available when deployed
    skipDeployment: true,
  })

  it('should only log RSC error once for nodejs runtime', async () => {
    await next.fetch('/server')
    await expectContainOnce(next, 'Custom error:server-node')
  })

  it('should only log RSC error once for edge runtime', async () => {
    await next.fetch('/server/edge')
    await expectContainOnce(next, 'Custom error:server-edge')
  })

  it('should only log SSR error once for nodejs runtime', async () => {
    await next.fetch('/client')
    await expectContainOnce(next, 'Custom error:client-node')
  })

  it('should only log SSR error once for edge runtime', async () => {
    await next.fetch('/client/edge')
    await expectContainOnce(next, 'Custom error:client-edge')
  })
})
Quest for Codev2.0.0
/
SIGN IN