Files
next.js/test/production/jest/transpile-packages.test.ts
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

39 lines
1.2 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
import { renderViaHTTP } from 'next-test-utils'
describe('next/jest', () => {
const { next } = nextTestSetup({
files: {
'pages/index.js': `import capitalize from '@hashicorp/platform-util/text/capitalize'
export default function Home() {
return capitalize('test')
}`,
'index.test.ts': `import capitalize from '@hashicorp/platform-util/text/capitalize'
it('should work', () => {
expect(capitalize('test')).toEqual('Test')
})`,
'jest.config.js': `module.exports = require('next/jest')({ dir: './' })()`,
'next.config.js': `module.exports = {
transpilePackages: ['@hashicorp/platform-util'],
}`,
},
packageJson: {
scripts: {
// Runs jest and bails if jest fails
build: 'next build && jest',
},
},
installCommand: 'pnpm i',
buildCommand: `pnpm build`,
dependencies: {
'@hashicorp/platform-util': '0.2.0',
'@types/react': 'latest',
jest: '27.4.7',
},
})
it('should work', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('Test')
})
})