[Next] jest 설치 및 설정

prerequisite

  • nextjs v12

참고

Setting up Jest (with the Rust Compiler)

설치

npm install --save-dev jest jest-environment-jsdom @testing-library/react @testing-library/jest-dom

설정

jest.config.js

const nextJest = require("next/jest");

const createJestConfig = nextJest({
  // Provide the path to your Next.js app to load next.config.js and .env files in your test environment
  dir: "./",
});

const customJestConfig = {
  moduleDirectories: ["node_modules", "<rootDir>/"],
  testEnvironment: "jest-environment-jsdom",
  collectCoverageFrom: [
    // 테스트 커버리지를 측정하고자 하는 파일
    "src/services/**/*.{js,jsx,ts,tsx}",
    "src/utils/*.{js,ts}",
  ],
};

module.exports = createJestConfig(customJestConfig);

디지엠유닛원 주식회사

  • 대표이사 권혁태
  • 개인정보보호책임자 정경영
  • 사업자등록번호 252-86-01619
  • 주소
    서울특별시 금천구 가산디지털1로 83, 6층 601호(가산동, 파트너스타워)
  • 이메일 unit1@dgmit.com