File size: 1,585 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import { createNext } from 'e2e-utils'
import { NextInstance } from 'e2e-utils'
describe('next/jest newLinkBehavior', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
'pages/index.jsx': `
import Link from 'next/link'
export default function Page() {
return <Link href='https://example.com'><div>Hello World!</div></Link>
}
`,
'test/index.test.jsx': `
import { render, screen, act } from '@testing-library/react'
import Page from '../pages/index'
it('Link', () => {
render(<Page />)
const link = screen.getByRole('link', { name: 'Hello World!' })
expect(link.getAttribute('href')).toBe('https://example.com')
})
`,
'jest.config.js': `
const nextJest = require('next/jest')
const createJestConfig = nextJest({ dir: './' })
module.exports = createJestConfig({
testEnvironment: 'jest-environment-jsdom',
})
`,
},
dependencies: {
jest: '29.7.0',
'jest-environment-jsdom': '29.7.0',
'@testing-library/react': '15.0.2',
},
packageJson: {
scripts: {
build: 'next build && jest --forceExit test/index.test.jsx',
},
},
installCommand: 'pnpm i',
skipStart: true,
buildCommand: `pnpm build`,
})
})
afterAll(() => next.destroy())
it(`should use new link behavior`, async () => {
await next.start()
})
})
|