jest.config.ts 769 B

1234567891011121314151617181920212223
  1. import type { Config } from "jest";
  2. import nextJest from "next/jest.js";
  3. const createJestConfig = nextJest({
  4. // Provide the path to your Next.js app to load next.config.js and .env files in your test environment
  5. dir: "./",
  6. });
  7. // Add any custom config to be passed to Jest
  8. const config: Config = {
  9. coverageProvider: "v8",
  10. testEnvironment: "jsdom",
  11. testMatch: ["**/*.test.js", "**/*.test.ts", "**/*.test.jsx", "**/*.test.tsx"],
  12. setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
  13. moduleNameMapper: {
  14. "^@/(.*)$": "<rootDir>/$1",
  15. },
  16. extensionsToTreatAsEsm: [".ts", ".tsx"],
  17. injectGlobals: true,
  18. };
  19. // createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
  20. export default createJestConfig(config);