Download next.js/test/e2e/config-schema-check/index.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/config-schema-check/index.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/config-schema-check/index.test.ts
-
curl -L -o index.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/config-schema-check/index.test.ts
1.62 kB
| import stripAnsi from 'strip-ansi' | |
| import { nextTestSetup } from 'e2e-utils' | |
| import { check } from 'next-test-utils' | |
| describe('next.config.js schema validating - defaultConfig', () => { | |
| const { next, skipped } = nextTestSetup({ | |
| files: { | |
| 'pages/index.js': ` | |
| export default function Page() { | |
| return <p>hello world</p> | |
| } | |
| `, | |
| 'next.config.js': ` | |
| module.exports = (phase, { defaultConfig }) => { | |
| return defaultConfig | |
| } | |
| `, | |
| }, | |
| skipDeployment: true, | |
| }) | |
| if (skipped) { | |
| return | |
| } | |
| it('should validate against defaultConfig', async () => { | |
| const output = stripAnsi(next.cliOutput) | |
| expect(output).not.toContain('Invalid next.config.js options detected') | |
| }) | |
| }) | |
| describe('next.config.js schema validating - invalid config', () => { | |
| const { next, isNextStart, skipped } = nextTestSetup({ | |
| files: { | |
| 'pages/index.js': ` | |
| export default function Page() { | |
| return <p>hello world</p> | |
| } | |
| `, | |
| 'next.config.js': ` | |
| module.exports = { | |
| badKey: 'badValue' | |
| } | |
| `, | |
| }, | |
| skipDeployment: true, | |
| }) | |
| if (skipped) { | |
| return | |
| } | |
| it('should warn the invalid next config', async () => { | |
| await check(() => { | |
| const output = stripAnsi(next.cliOutput) | |
| const warningTimes = output.split('badKey').length - 1 | |
| expect(output).toContain('Invalid next.config.js options detected') | |
| expect(output).toContain('badKey') | |
| // for next start and next build we both display the warnings | |
| expect(warningTimes).toBe(isNextStart ? 2 : 1) | |
| return 'success' | |
| }, 'success') | |
| }) | |
| }) | |