Files
supabase/apps/www/next.config.test.ts
Ivan Vasilov a41d7138a5 feat: add vitest configuration and tests for X-Robots-Tag headers (#42873)
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.
2026-02-17 07:15:55 -07:00

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' }],
}),
])
)
})
})