mirror of
https://github.com/supabase/supabase.git
synced 2026-06-17 05:08:49 +08:00
This pull request introduces a testing setup for the Next.js app using Vitest. The main changes include the addition of a test configuration, test scripts, and a sample test for the Next.js config. It also adds relevant dependencies to support Vitest and path resolution, and updates the lock file accordingly. Testing infrastructure: * Added a sample test file `next.config.test.ts` using Vitest to verify that specific headers are present in the Next.js configuration. * Created a Vitest configuration file `vitest.config.ts` with TypeScript path resolution support via the `vite-tsconfig-paths` plugin. Scripts and dependencies: * Added `test` and `test:watch` scripts to `package.json` for running and watching tests, and included `vitest` and `vite-tsconfig-paths` as dev dependencies.
27 lines
860 B
TypeScript
27 lines
860 B
TypeScript
import type { NextConfig } from 'next'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
vi.mock('@sentry/nextjs', () => ({
|
|
withSentryConfig: (configFn: any) => (typeof configFn === 'function' ? configFn() : configFn),
|
|
}))
|
|
|
|
describe('next.config.mjs', () => {
|
|
it('expect the headers to always have X-Robots-Tag', async () => {
|
|
const { default: config } = (await import('./next.config.mjs')) as { default: NextConfig }
|
|
const headers = (await config.headers?.()) || []
|
|
|
|
expect(headers).toEqual(
|
|
expect.arrayContaining([
|
|
expect.objectContaining({
|
|
source: '/(docs|blog)/:path*',
|
|
headers: [{ key: 'X-Robots-Tag', value: 'all' }],
|
|
}),
|
|
expect.objectContaining({
|
|
source: '/dashboard/:path*',
|
|
headers: [{ key: 'X-Robots-Tag', value: 'noindex' }],
|
|
}),
|
|
])
|
|
)
|
|
})
|
|
})
|