Skip to content
Snippets Groups Projects
jest.config.mjs 1.09 KiB
import nextJest from 'next/jest.js';

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

// Custom client config to be passed to Jest.
const clientTestConfig = {
    displayName: "client",
    testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/__tests__/api/"],
    setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
    testEnvironment: "jest-environment-jsdom",
};

// Custom server config to be passed to Jest.
const serverTestConfig = {
    displayName: "server",
    testMatch: ["**/__tests__/api/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
    testEnvironment: "jest-environment-node",
};

// Add any custom config to be passed to Jest
/** @type {import('jest').Config} */
const config = {
    // Add more setup options before each test is run
    projects: [await createJestConfig(clientTestConfig)(), await createJestConfig(serverTestConfig)()],
    collectCoverageFrom: [
        '**/app/api/**',
        '!**/node_modules/**',
        '!**/vendor/**',
      ]
};

export default config;