next.js/test/development/app-dir/app-routes-error/index.test.ts
index.test.ts39 lines1.0 KB
import { nextTestSetup } from 'e2e-utils'
import { check } from 'next-test-utils'

describe('app-dir - app routes errors', () => {
  const { next } = nextTestSetup({
    files: __dirname,
  })

  describe('bad lowercase exports', () => {
    it.each([
      ['get'],
      ['head'],
      ['options'],
      ['post'],
      ['put'],
      ['delete'],
      ['patch'],
    ])(
      'should print an error when using lowercase %p in dev',
      async (method: string) => {
        await next.fetch('/lowercase/' + method)

        await check(() => {
          expect(next.cliOutput).toContain(
            `Detected lowercase method '${method}' in`
          )
          expect(next.cliOutput).toContain(
            `Export the uppercase '${method.toUpperCase()}' method name to fix this error.`
          )
          expect(next.cliOutput).toMatch(
            /Detected lowercase method '.+' in '.+\/route\.js'\. Export the uppercase '.+' method name to fix this error\./
          )
          return 'yes'
        }, 'yes')
      }
    )
  })
})
Quest for Codev2.0.0
/
SIGN IN