-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjest.config.unit.ts
More file actions
34 lines (32 loc) · 1.32 KB
/
Copy pathjest.config.unit.ts
File metadata and controls
34 lines (32 loc) · 1.32 KB
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
import type { Config } from 'jest';
// Pure unit tests: run entirely within Jest with no server, Postgres, S3, or Supabase.
// Tests opt in by using the `.unit.test.ts` suffix. Crucially, this config does NOT load
// `jest_setup.ts`, which connects to and truncates a real database.
//
// Transformed with @swc/jest (not next/jest's transformer) because the app uses standard-proposal
// decorators / `accessor` fields, which next/jest's SWC setup doesn't enable. Unit tests need no
// Next-specific transforms (CSS, fonts, etc.), so a plain SWC transform is enough.
const config: Config = {
testMatch: ['**/*.unit.test.[jt]s?(x)'],
setupFilesAfterEnv: ['<rootDir>/src/services/jest_setup.unit.ts'],
modulePaths: ['<rootDir>/src'],
moduleNameMapper: {
// Jest's resolver doesn't read the "exports" map, and zip.js' subpaths are ESM-only. The CJS
// bundle is the same native-codec build, just not tree-shaken.
'^@zip\\.js/zip\\.js/lib/zip-core-native\\.js$': '@zip.js/zip.js/index-native.cjs',
},
transform: {
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
jsc: {
parser: { syntax: 'typescript', tsx: true, decorators: true },
transform: { decoratorVersion: '2022-03' },
target: 'es2022',
keepClassNames: true,
},
},
],
},
};
export default config;