참고 링크
npm i --save-dev jest @types/jest jest-environment-jsdom
- jest.config.js
const nextJest = require('next/jest')
const createJestConfig = nextJest({ dir: './' })
const customJestConfig = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
testEnvironment: 'jest-environment-jsdom'
}
module.exports = createJestConfig(customJestConfig)
npm i --save-dev @testing-library/react @testing-library/jest-dom
- jest.setup.ts
import '@testing-library/jest-dom';
- package.json
"test": "jest --watch --coverage",
"test:ci": "jest --ci"