Repository navigation
Expand file tree
/
Copy pathjest.config.ts
More file actions
64 lines (62 loc) · 2.3 KB
/
Copy pathjest.config.ts
File metadata and controls
64 lines (62 loc) · 2.3 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import type { Config } from 'jest';
/**
* Root Jest configuration for WREN Writing Coach Node/TypeScript code
* (CDK infrastructure + frontend logic). Uses ts-jest so tests can be
* authored in TypeScript with the repo's strict compiler settings.
*
* Per-package configs (cdk/, frontend/) may extend or override this once
* those packages are scaffolded; until then this discovers any `*.test.ts`
* outside node_modules and the build output directories.
*/
const config: Config = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
// The base tsconfig uses classic (Node10) resolution, which does not
// read package.json "exports" subpaths. Add a compiler `paths` mapping
// so ts-jest type-checks the @wren/admin subpath import used by
// askWren.ts / lambda handlers (runtime resolution is handled by
// moduleNameMapper below).
tsconfig: {
baseUrl: '.',
paths: {
'@wren/admin/lifetimeUsagePolicy': [
'./backend/admin/src/lifetimeUsagePolicy.ts',
],
'@wren/types/signupEmailDomains': [
'./types/src/signupEmailDomains.ts',
],
},
},
},
],
},
// Explicit test-only env (e.g. PROMPT_GUARDRAIL_SKIP for the admin guardrail).
setupFiles: ['<rootDir>/testing/typescript/jest.setup.ts'],
testMatch: ['<rootDir>/**/*.test.ts'],
testPathIgnorePatterns: [
'/node_modules/',
'/cdk.out/',
'/dist/',
'/cdk/',
// Frontend tests use Vitest (not Jest) — they are run separately via `vite test`.
'frontend/src/',
],
modulePathIgnorePatterns: ['/node_modules/', '/cdk.out/', '/dist/'],
// Map NodeNext-style ".js" relative imports onto their ".ts" sources.
moduleNameMapper: {
// Workspace package subpath exports Jest's resolver doesn't read from
// package.json "exports". Map the @wren/admin subpath to its source so
// tests importing modules that depend on it resolve without a build step.
'^@wren/admin/lifetimeUsagePolicy$':
'<rootDir>/backend/admin/src/lifetimeUsagePolicy.ts',
'^@wren/types/signupEmailDomains$':
'<rootDir>/types/src/signupEmailDomains.ts',
'^(\\.{1,2}/.*)\\.js$': '$1',
},
clearMocks: true,
};
export default config;