04daf7eb06
Should be good to land and it got tests covered. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { createNext } from 'e2e-utils'
|
|
import { NextInstance } from 'test/lib/next-modes/base'
|
|
import { renderViaHTTP } from 'next-test-utils'
|
|
describe('next/jest', () => {
|
|
let next: NextInstance
|
|
|
|
beforeAll(async () => {
|
|
next = await createNext({
|
|
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 && yarn jest',
|
|
},
|
|
},
|
|
buildCommand: `yarn build`,
|
|
dependencies: {
|
|
'@hashicorp/platform-util': '0.2.0',
|
|
'@types/react': 'latest',
|
|
jest: '27.4.7',
|
|
},
|
|
})
|
|
})
|
|
afterAll(() => next.destroy())
|
|
|
|
it('should work', async () => {
|
|
const html = await renderViaHTTP(next.url, '/')
|
|
expect(html).toContain('Test')
|
|
})
|
|
})
|