Files
4588a73542 Convert tests using createNext -> nextTestSetup (#93767)
## What?

Converts existing `createNext()` usage into `nextTestSetup()`. 

`createNext()` was the setup step we had before `nextTestSetup()` was
added.

This PR focused on the simple conversion cases. There will be a
follow-up to complete the last few.

---------

Co-authored-by: Cursor <[email protected]>
2026-05-12 13:16:31 +02:00

50 lines
1.2 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
import { check, renderViaHTTP } from 'next-test-utils'
describe('ENOENT during require', () => {
const { next } = nextTestSetup({
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: {},
})
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')
})
})