-
[Next.js] Jest + Typescript + Next.js프로그래밍/Next.js 2023. 12. 7. 11:37
개요
- 설치 및 적용
Get Started
install)
pnpm create next-app
add dependencies)
pnpm add -D @testing-library/jest-dom @testing-library/react @testing-library/user-event jest jest-environment-jsdom ts-jest
script)
// package.json "scripts": { ... "test": "jest", "test:watch": "jest --watchAll" },
jset config)
// jest.config.js const nextJest = require('next/jest') const createJestConfig = nextJest({ dir: './', }) const customJestConfig = { setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], testEnvironment: 'jest-environment-jsdom', preset: 'ts-jest', } module.exports = createJestConfig(customJestConfig) // jset.setup.js import '@testing-library/jest-dom/extend-expect'
eslint setting)
pnpm add -D eslint-plugin-jest-dom eslint-plugin-testing-library
pnpm add -D eslint-plugin-jest-dom eslint-plugin-testing-library
참고자료 : Docs , OpenSource , Youtube ,
'프로그래밍 > Next.js' 카테고리의 다른 글
[Next.js] 패키지 가져오기 최적화 (0) 2023.12.05 [드림코딩엘리] Next.js 환경설정 (0) 2023.08.01 [드림코딩엘리] Next.js 주요개념 (2강) (0) 2023.08.01