Download next.js/test/production/enoent-during-require/index.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/production/enoent-during-require/index.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/production/enoent-during-require/index.test.ts
-
curl -L -o index.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/production/enoent-during-require/index.test.ts
1.44 kB
| import { createNext } from 'e2e-utils' | |
| import { NextInstance } from 'e2e-utils' | |
| import { check, renderViaHTTP } from 'next-test-utils' | |
| describe('ENOENT during require', () => { | |
| let next: NextInstance | |
| beforeAll(async () => { | |
| next = await createNext({ | |
| files: { | |
| 'pages/_app.js': ` | |
| import App from 'next/app' | |
| if (typeof window === 'undefined') { | |
| if (process.env.NEXT_PHASE !== 'phase-production-build') { | |
| require('fs').readdirSync('non-existent-folder') | |
| } | |
| } | |
| export default App | |
| `, | |
| 'pages/index.js': ` | |
| export function getStaticProps() { | |
| console.log('revalidate /') | |
| return { | |
| props: { | |
| now: Date.now() | |
| }, | |
| revalidate: 1 | |
| } | |
| } | |
| export default function Page() { | |
| return <p>hello world</p> | |
| } | |
| `, | |
| }, | |
| dependencies: {}, | |
| }) | |
| }) | |
| afterAll(() => next.destroy()) | |
| it('should show ENOENT error correctly', async () => { | |
| await check(async () => { | |
| await renderViaHTTP(next.url, '/') | |
| console.error(next.cliOutput) | |
| return next.cliOutput.includes('non-existent-folder') | |
| ? 'success' | |
| : next.cliOutput | |
| }, 'success') | |
| expect(next.cliOutput).not.toContain('Cannot destructure property') | |
| }) | |
| }) | |