-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.mjs
42 lines (38 loc) · 1.27 KB
/
jest.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import nextJest from "next/jest.js";
//-configuration object must always be JSON-serializable.
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: "./",
});
// 👇 Setup overlap for both the ssr & csr testing
/** @type {import('jest').Config} */
const sharedConfig = {
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
transform: { "^.+\\.ts?$": "ts-jest" },
coveragePathIgnorePatterns: ["<rootDir>/node_modules/"],
preset: "ts-jest",
};
//👇 Setup for testing client side rendered components
const clientTestConfig = {
...sharedConfig,
testEnvironment: "jest-environment-jsdom",
testMatch: ["**/__tests__/*.test.tsx", "**/__tests__/page-*"],
};
//👇 Setup for testing server side rendered components
const serverTestConfig = {
...sharedConfig,
testEnvironment: "jest-environment-node",
testMatch: ["**/__tests__/*.server.test.tsx"],
};
const config = {
projects: [
await createJestConfig(clientTestConfig)(),
await createJestConfig(serverTestConfig)(),
],
silent: true,
preset: "ts-jest",
verbose: true,
automock: true,
};
//createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
export default config;