@codyswann/lisa 1.13.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdk/copy-overwrite/jest.cdk.ts +71 -0
- package/cdk/copy-overwrite/jest.config.ts +28 -0
- package/cdk/copy-overwrite/tsconfig.cdk.json +14 -0
- package/cdk/copy-overwrite/tsconfig.json +3 -0
- package/cdk/create-only/tsconfig.local.json +4 -0
- package/expo/copy-overwrite/jest.config.ts +28 -0
- package/expo/copy-overwrite/jest.expo.ts +76 -0
- package/expo/copy-overwrite/tsconfig.expo.json +9 -0
- package/expo/copy-overwrite/tsconfig.json +3 -0
- package/expo/create-only/tsconfig.local.json +9 -0
- package/nestjs/copy-overwrite/jest.config.ts +28 -0
- package/nestjs/copy-overwrite/jest.nestjs.ts +89 -0
- package/nestjs/copy-overwrite/tsconfig.build.json +5 -0
- package/nestjs/copy-overwrite/tsconfig.json +5 -0
- package/nestjs/copy-overwrite/tsconfig.nestjs.json +13 -0
- package/nestjs/copy-overwrite/tsconfig.spec.json +7 -0
- package/nestjs/create-only/tsconfig.local.json +6 -0
- package/package.json +1 -1
- package/typescript/copy-overwrite/jest.base.ts +112 -0
- package/typescript/copy-overwrite/jest.config.ts +34 -0
- package/typescript/copy-overwrite/jest.typescript.ts +72 -0
- package/typescript/copy-overwrite/tsconfig.base.json +15 -0
- package/typescript/copy-overwrite/tsconfig.json +5 -0
- package/typescript/copy-overwrite/tsconfig.typescript.json +11 -0
- package/typescript/create-only/jest.config.local.ts +30 -0
- package/typescript/create-only/jest.thresholds.json +8 -0
- package/typescript/create-only/tsconfig.local.json +6 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is managed by Lisa.
|
|
3
|
+
* Do not edit directly — changes will be overwritten on the next `lisa` run.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Jest Configuration - CDK Stack
|
|
8
|
+
*
|
|
9
|
+
* Provides AWS CDK-specific Jest configuration targeting
|
|
10
|
+
* the test/ directory with spec and integration-spec patterns.
|
|
11
|
+
*
|
|
12
|
+
* Inheritance chain:
|
|
13
|
+
* jest.cdk.ts (this file)
|
|
14
|
+
* └── jest.base.ts
|
|
15
|
+
*
|
|
16
|
+
* @see https://jestjs.io/docs/configuration
|
|
17
|
+
* @module jest.cdk
|
|
18
|
+
*/
|
|
19
|
+
import type { Config } from "jest";
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
defaultCoverageExclusions,
|
|
23
|
+
defaultThresholds,
|
|
24
|
+
mergeConfigs,
|
|
25
|
+
mergeThresholds,
|
|
26
|
+
} from "./jest.base.ts";
|
|
27
|
+
|
|
28
|
+
// Re-export base utilities for entry-point configs
|
|
29
|
+
export {
|
|
30
|
+
defaultCoverageExclusions,
|
|
31
|
+
defaultThresholds,
|
|
32
|
+
mergeConfigs,
|
|
33
|
+
mergeThresholds,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Options for configuring the CDK Jest config factory.
|
|
38
|
+
*/
|
|
39
|
+
interface CdkJestOptions {
|
|
40
|
+
/** Coverage thresholds (merged defaults + project overrides) */
|
|
41
|
+
readonly thresholds?: Config["coverageThreshold"];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Creates a Jest configuration for AWS CDK projects.
|
|
46
|
+
*
|
|
47
|
+
* @param options - Configuration options for threshold overrides
|
|
48
|
+
* @param options.thresholds - Coverage thresholds (merged defaults + project overrides)
|
|
49
|
+
* @returns Jest config object with ts-jest transform, node environment, and CDK-specific paths
|
|
50
|
+
* @remarks CDK projects typically use CommonJS modules and keep tests in a
|
|
51
|
+
* separate test/ directory. Coverage is collected only from lib/ and util/
|
|
52
|
+
* directories since bin/ contains entry-point code with minimal logic.
|
|
53
|
+
*/
|
|
54
|
+
export const getCdkJestConfig = ({
|
|
55
|
+
thresholds = defaultThresholds,
|
|
56
|
+
}: CdkJestOptions = {}): Config => ({
|
|
57
|
+
testEnvironment: "node",
|
|
58
|
+
roots: ["<rootDir>/test"],
|
|
59
|
+
testRegex: "(.*\\.(spec|integration-spec)\\.ts)$",
|
|
60
|
+
transform: {
|
|
61
|
+
"^.+\\.ts$": "ts-jest",
|
|
62
|
+
},
|
|
63
|
+
moduleFileExtensions: ["js", "json", "ts"],
|
|
64
|
+
collectCoverageFrom: [
|
|
65
|
+
"lib/**/*.ts",
|
|
66
|
+
"util/**/*.ts",
|
|
67
|
+
...defaultCoverageExclusions,
|
|
68
|
+
],
|
|
69
|
+
coverageThreshold: thresholds,
|
|
70
|
+
testTimeout: 10000,
|
|
71
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is managed by Lisa.
|
|
3
|
+
* Do not edit directly — changes will be overwritten on the next `lisa` run.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Jest Configuration - Main Entry Point (CDK)
|
|
8
|
+
*
|
|
9
|
+
* Imports the CDK-specific configuration and project-local customizations.
|
|
10
|
+
* Do not modify this file directly - use jest.config.local.ts for project-specific settings.
|
|
11
|
+
*
|
|
12
|
+
* Inheritance chain:
|
|
13
|
+
* jest.config.ts (this file)
|
|
14
|
+
* └── jest.cdk.ts
|
|
15
|
+
* └── jest.base.ts
|
|
16
|
+
*
|
|
17
|
+
* @see https://jestjs.io/docs/configuration
|
|
18
|
+
* @module jest.config
|
|
19
|
+
*/
|
|
20
|
+
import { mergeConfigs, mergeThresholds } from "./jest.base.ts";
|
|
21
|
+
import { defaultThresholds, getCdkJestConfig } from "./jest.cdk.ts";
|
|
22
|
+
|
|
23
|
+
import localConfig from "./jest.config.local.ts";
|
|
24
|
+
import thresholdsOverrides from "./jest.thresholds.json" with { type: "json" };
|
|
25
|
+
|
|
26
|
+
const thresholds = mergeThresholds(defaultThresholds, thresholdsOverrides);
|
|
27
|
+
|
|
28
|
+
export default mergeConfigs(getCdkJestConfig({ thresholds }), localConfig);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2020",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"lib": ["es2020"],
|
|
7
|
+
"inlineSourceMap": true,
|
|
8
|
+
"inlineSources": true,
|
|
9
|
+
"experimentalDecorators": true,
|
|
10
|
+
"strictPropertyInitialization": false,
|
|
11
|
+
"noUnusedLocals": false,
|
|
12
|
+
"noUnusedParameters": false
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is managed by Lisa.
|
|
3
|
+
* Do not edit directly — changes will be overwritten on the next `lisa` run.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Jest Configuration - Main Entry Point (Expo)
|
|
8
|
+
*
|
|
9
|
+
* Imports the Expo-specific configuration and project-local customizations.
|
|
10
|
+
* Do not modify this file directly - use jest.config.local.ts for project-specific settings.
|
|
11
|
+
*
|
|
12
|
+
* Inheritance chain:
|
|
13
|
+
* jest.config.ts (this file)
|
|
14
|
+
* └── jest.expo.ts
|
|
15
|
+
* └── jest.base.ts
|
|
16
|
+
*
|
|
17
|
+
* @see https://jestjs.io/docs/configuration
|
|
18
|
+
* @module jest.config
|
|
19
|
+
*/
|
|
20
|
+
import { mergeConfigs, mergeThresholds } from "./jest.base.ts";
|
|
21
|
+
import { defaultThresholds, getExpoJestConfig } from "./jest.expo.ts";
|
|
22
|
+
|
|
23
|
+
import localConfig from "./jest.config.local.ts";
|
|
24
|
+
import thresholdsOverrides from "./jest.thresholds.json" with { type: "json" };
|
|
25
|
+
|
|
26
|
+
const thresholds = mergeThresholds(defaultThresholds, thresholdsOverrides);
|
|
27
|
+
|
|
28
|
+
export default mergeConfigs(getExpoJestConfig({ thresholds }), localConfig);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is managed by Lisa.
|
|
3
|
+
* Do not edit directly — changes will be overwritten on the next `lisa` run.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Jest Configuration - Expo Stack
|
|
8
|
+
*
|
|
9
|
+
* Provides Expo/React Native-specific Jest configuration.
|
|
10
|
+
* Extends the base Jest utilities for coverage thresholds and merging.
|
|
11
|
+
*
|
|
12
|
+
* Inheritance chain:
|
|
13
|
+
* jest.expo.ts (this file)
|
|
14
|
+
* └── jest.base.ts
|
|
15
|
+
*
|
|
16
|
+
* @see https://jestjs.io/docs/configuration
|
|
17
|
+
* @module jest.expo
|
|
18
|
+
*/
|
|
19
|
+
import type { Config } from "jest";
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
defaultCoverageExclusions,
|
|
23
|
+
defaultThresholds,
|
|
24
|
+
mergeConfigs,
|
|
25
|
+
mergeThresholds,
|
|
26
|
+
} from "./jest.base.ts";
|
|
27
|
+
|
|
28
|
+
// Re-export base utilities for entry-point configs
|
|
29
|
+
export {
|
|
30
|
+
defaultCoverageExclusions,
|
|
31
|
+
defaultThresholds,
|
|
32
|
+
mergeConfigs,
|
|
33
|
+
mergeThresholds,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Options for configuring the Expo Jest config factory.
|
|
38
|
+
*/
|
|
39
|
+
interface ExpoJestOptions {
|
|
40
|
+
/** Coverage thresholds (merged defaults + project overrides) */
|
|
41
|
+
readonly thresholds?: Config["coverageThreshold"];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Creates a Jest configuration for Expo/React Native projects.
|
|
46
|
+
*
|
|
47
|
+
* @param options - Configuration options for threshold overrides
|
|
48
|
+
* @param options.thresholds - Coverage thresholds (merged defaults + project overrides)
|
|
49
|
+
* @returns Jest config object with jsdom environment, babel-jest transform, and React Native resolver
|
|
50
|
+
* @remarks Uses jest-expo preset which provides platform-specific test resolution
|
|
51
|
+
* and proper React Native module mocking out of the box.
|
|
52
|
+
*/
|
|
53
|
+
export const getExpoJestConfig = ({
|
|
54
|
+
thresholds = defaultThresholds,
|
|
55
|
+
}: ExpoJestOptions = {}): Config => ({
|
|
56
|
+
preset: "jest-expo",
|
|
57
|
+
testEnvironment: "jsdom",
|
|
58
|
+
testMatch: [
|
|
59
|
+
"<rootDir>/**/*.test.ts",
|
|
60
|
+
"<rootDir>/**/*.test.tsx",
|
|
61
|
+
"<rootDir>/**/__tests__/**/*.ts",
|
|
62
|
+
"<rootDir>/**/__tests__/**/*.tsx",
|
|
63
|
+
],
|
|
64
|
+
testPathIgnorePatterns: ["/node_modules/", "/dist/", "/.expo/"],
|
|
65
|
+
transformIgnorePatterns: [
|
|
66
|
+
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@sentry/react-native|native-base|react-native-svg|@gluestack-ui/.*|@gluestack-style/.*|nativewind|react-native-css-interop)",
|
|
67
|
+
],
|
|
68
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
|
|
69
|
+
collectCoverageFrom: [
|
|
70
|
+
"**/*.{ts,tsx}",
|
|
71
|
+
"!**/*.d.ts",
|
|
72
|
+
...defaultCoverageExclusions,
|
|
73
|
+
],
|
|
74
|
+
coverageThreshold: thresholds,
|
|
75
|
+
testTimeout: 10000,
|
|
76
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is managed by Lisa.
|
|
3
|
+
* Do not edit directly — changes will be overwritten on the next `lisa` run.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Jest Configuration - Main Entry Point (NestJS)
|
|
8
|
+
*
|
|
9
|
+
* Imports the NestJS-specific configuration and project-local customizations.
|
|
10
|
+
* Do not modify this file directly - use jest.config.local.ts for project-specific settings.
|
|
11
|
+
*
|
|
12
|
+
* Inheritance chain:
|
|
13
|
+
* jest.config.ts (this file)
|
|
14
|
+
* └── jest.nestjs.ts
|
|
15
|
+
* └── jest.base.ts
|
|
16
|
+
*
|
|
17
|
+
* @see https://jestjs.io/docs/configuration
|
|
18
|
+
* @module jest.config
|
|
19
|
+
*/
|
|
20
|
+
import { mergeConfigs, mergeThresholds } from "./jest.base.ts";
|
|
21
|
+
import { defaultThresholds, getNestjsJestConfig } from "./jest.nestjs.ts";
|
|
22
|
+
|
|
23
|
+
import localConfig from "./jest.config.local.ts";
|
|
24
|
+
import thresholdsOverrides from "./jest.thresholds.json" with { type: "json" };
|
|
25
|
+
|
|
26
|
+
const thresholds = mergeThresholds(defaultThresholds, thresholdsOverrides);
|
|
27
|
+
|
|
28
|
+
export default mergeConfigs(getNestjsJestConfig({ thresholds }), localConfig);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is managed by Lisa.
|
|
3
|
+
* Do not edit directly — changes will be overwritten on the next `lisa` run.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Jest Configuration - NestJS Stack
|
|
8
|
+
*
|
|
9
|
+
* Provides NestJS-specific Jest configuration with extensive coverage
|
|
10
|
+
* exclusions for generated files, DTOs, entities, and modules.
|
|
11
|
+
*
|
|
12
|
+
* Inheritance chain:
|
|
13
|
+
* jest.nestjs.ts (this file)
|
|
14
|
+
* └── jest.base.ts
|
|
15
|
+
*
|
|
16
|
+
* @see https://jestjs.io/docs/configuration
|
|
17
|
+
* @module jest.nestjs
|
|
18
|
+
*/
|
|
19
|
+
import type { Config } from "jest";
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
defaultCoverageExclusions,
|
|
23
|
+
defaultThresholds,
|
|
24
|
+
mergeConfigs,
|
|
25
|
+
mergeThresholds,
|
|
26
|
+
} from "./jest.base.ts";
|
|
27
|
+
|
|
28
|
+
// Re-export base utilities for entry-point configs
|
|
29
|
+
export {
|
|
30
|
+
defaultCoverageExclusions,
|
|
31
|
+
defaultThresholds,
|
|
32
|
+
mergeConfigs,
|
|
33
|
+
mergeThresholds,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Options for configuring the NestJS Jest config factory.
|
|
38
|
+
*/
|
|
39
|
+
interface NestjsJestOptions {
|
|
40
|
+
/** Coverage thresholds (merged defaults + project overrides) */
|
|
41
|
+
readonly thresholds?: Config["coverageThreshold"];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* NestJS-specific patterns excluded from coverage collection.
|
|
46
|
+
* These are generated or boilerplate files that don't benefit from coverage tracking.
|
|
47
|
+
*/
|
|
48
|
+
const nestjsCoverageExclusions: readonly string[] = [
|
|
49
|
+
...defaultCoverageExclusions,
|
|
50
|
+
"!**/*.entity.ts",
|
|
51
|
+
"!**/*.dto.ts",
|
|
52
|
+
"!**/*.input.ts",
|
|
53
|
+
"!**/*.args.ts",
|
|
54
|
+
"!**/*.model.ts",
|
|
55
|
+
"!**/*.module.ts",
|
|
56
|
+
"!**/*.factory.ts",
|
|
57
|
+
"!**/*.enum.ts",
|
|
58
|
+
"!**/*.interface.ts",
|
|
59
|
+
"!**/*.constants.ts",
|
|
60
|
+
"!**/database/migrations/**",
|
|
61
|
+
"!**/database/seeds/**",
|
|
62
|
+
"!**/graphql/**",
|
|
63
|
+
"!**/main.ts",
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Creates a Jest configuration for NestJS projects.
|
|
68
|
+
*
|
|
69
|
+
* @param options - Configuration options for threshold overrides
|
|
70
|
+
* @param options.thresholds - Coverage thresholds (merged defaults + project overrides)
|
|
71
|
+
* @returns Jest config object with ts-jest transform, node environment, and NestJS-specific exclusions
|
|
72
|
+
* @remarks NestJS projects use CommonJS modules and spec.ts test file convention.
|
|
73
|
+
* Coverage excludes entities, DTOs, modules, and other boilerplate files
|
|
74
|
+
* that are better validated through integration tests.
|
|
75
|
+
*/
|
|
76
|
+
export const getNestjsJestConfig = ({
|
|
77
|
+
thresholds = defaultThresholds,
|
|
78
|
+
}: NestjsJestOptions = {}): Config => ({
|
|
79
|
+
testEnvironment: "node",
|
|
80
|
+
rootDir: "src",
|
|
81
|
+
testRegex: ".*\\.spec\\.ts$",
|
|
82
|
+
transform: {
|
|
83
|
+
"^.+\\.ts$": "ts-jest",
|
|
84
|
+
},
|
|
85
|
+
moduleFileExtensions: ["js", "json", "ts"],
|
|
86
|
+
collectCoverageFrom: ["**/*.ts", ...nestjsCoverageExclusions],
|
|
87
|
+
coverageThreshold: thresholds,
|
|
88
|
+
testTimeout: 10000,
|
|
89
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"target": "ES2021",
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"outDir": ".build",
|
|
11
|
+
"baseUrl": "./"
|
|
12
|
+
}
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
},
|
|
86
86
|
"resolutions": {},
|
|
87
87
|
"name": "@codyswann/lisa",
|
|
88
|
-
"version": "1.
|
|
88
|
+
"version": "1.14.0",
|
|
89
89
|
"description": "Claude Code governance framework that applies guardrails, guidance, and automated enforcement to projects",
|
|
90
90
|
"main": "dist/index.js",
|
|
91
91
|
"bin": {
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is managed by Lisa.
|
|
3
|
+
* Do not edit directly — changes will be overwritten on the next `lisa` run.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Jest Configuration - Shared Base
|
|
8
|
+
*
|
|
9
|
+
* Exports shared configuration pieces that can be imported by
|
|
10
|
+
* project-specific jest.config.ts files. Reduces duplication between
|
|
11
|
+
* typescript, expo, nestjs, and other project type configurations.
|
|
12
|
+
*
|
|
13
|
+
* @see https://jestjs.io/docs/configuration
|
|
14
|
+
* @module jest.base
|
|
15
|
+
*/
|
|
16
|
+
import type { Config } from "jest";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Default coverage thresholds used when not specified in project config.
|
|
20
|
+
* Projects can override via jest.thresholds.json.
|
|
21
|
+
*/
|
|
22
|
+
export const defaultThresholds: Config["coverageThreshold"] = {
|
|
23
|
+
global: {
|
|
24
|
+
statements: 70,
|
|
25
|
+
branches: 70,
|
|
26
|
+
functions: 70,
|
|
27
|
+
lines: 70,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Default patterns to exclude from coverage collection.
|
|
33
|
+
* Common across all stacks — stack-specific configs extend this list.
|
|
34
|
+
*/
|
|
35
|
+
export const defaultCoverageExclusions: readonly string[] = [
|
|
36
|
+
"!**/*.d.ts",
|
|
37
|
+
"!**/index.ts",
|
|
38
|
+
"!**/node_modules/**",
|
|
39
|
+
"!**/dist/**",
|
|
40
|
+
"!**/*.test.ts",
|
|
41
|
+
"!**/*.spec.ts",
|
|
42
|
+
"!**/*.mock.ts",
|
|
43
|
+
"!**/test/**",
|
|
44
|
+
"!**/tests/**",
|
|
45
|
+
"!**/__tests__/**",
|
|
46
|
+
"!**/__mocks__/**",
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Merges project-specific threshold overrides into default thresholds.
|
|
51
|
+
* Allows projects to selectively raise or lower coverage requirements
|
|
52
|
+
* via jest.thresholds.json without replacing the entire threshold object.
|
|
53
|
+
*
|
|
54
|
+
* Spreads all top-level keys from both defaults and overrides (including
|
|
55
|
+
* per-path/per-file patterns like `"./src/api/": { branches: 80 }`).
|
|
56
|
+
* The `global` key receives special treatment: its properties are
|
|
57
|
+
* shallow-merged so individual metrics can be overridden without
|
|
58
|
+
* replacing the entire global object.
|
|
59
|
+
*
|
|
60
|
+
* @param defaults - Base thresholds from the stack config
|
|
61
|
+
* @param overrides - Project-specific overrides from jest.thresholds.json
|
|
62
|
+
* @returns Merged thresholds with overrides taking precedence
|
|
63
|
+
*/
|
|
64
|
+
export const mergeThresholds = (
|
|
65
|
+
defaults: Config["coverageThreshold"],
|
|
66
|
+
overrides: Config["coverageThreshold"]
|
|
67
|
+
): Config["coverageThreshold"] => ({
|
|
68
|
+
...defaults,
|
|
69
|
+
...overrides,
|
|
70
|
+
global: {
|
|
71
|
+
...(defaults?.global as Record<string, number>),
|
|
72
|
+
...(overrides?.global as Record<string, number>),
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Merges multiple Jest configs together with array concatenation and
|
|
78
|
+
* shallow object merging. Later configs take precedence for scalar values.
|
|
79
|
+
* Arrays are concatenated and deduplicated to allow additive composition.
|
|
80
|
+
*
|
|
81
|
+
* @param configs - Jest config objects to merge in order of precedence
|
|
82
|
+
* @returns Single merged Jest config
|
|
83
|
+
* @remarks Used by entry-point jest.config.ts files to combine stack config
|
|
84
|
+
* with project-local overrides without losing array values like testMatch
|
|
85
|
+
* or collectCoverageFrom.
|
|
86
|
+
*/
|
|
87
|
+
export const mergeConfigs = (...configs: Config[]): Config =>
|
|
88
|
+
configs.reduce(
|
|
89
|
+
(acc, config) =>
|
|
90
|
+
(Object.keys(config) as (keyof Config)[]).reduce((merged, key) => {
|
|
91
|
+
const accVal = acc[key];
|
|
92
|
+
const configVal = config[key];
|
|
93
|
+
|
|
94
|
+
const mergedValue =
|
|
95
|
+
Array.isArray(accVal) && Array.isArray(configVal)
|
|
96
|
+
? [...new Set([...accVal, ...configVal])]
|
|
97
|
+
: typeof accVal === "object" &&
|
|
98
|
+
accVal !== null &&
|
|
99
|
+
!Array.isArray(accVal) &&
|
|
100
|
+
typeof configVal === "object" &&
|
|
101
|
+
configVal !== null &&
|
|
102
|
+
!Array.isArray(configVal)
|
|
103
|
+
? {
|
|
104
|
+
...(accVal as Record<string, unknown>),
|
|
105
|
+
...(configVal as Record<string, unknown>),
|
|
106
|
+
}
|
|
107
|
+
: configVal;
|
|
108
|
+
|
|
109
|
+
return { ...merged, [key]: mergedValue };
|
|
110
|
+
}, acc),
|
|
111
|
+
{} as Config
|
|
112
|
+
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is managed by Lisa.
|
|
3
|
+
* Do not edit directly — changes will be overwritten on the next `lisa` run.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Jest Configuration - Main Entry Point (TypeScript)
|
|
8
|
+
*
|
|
9
|
+
* Imports the TypeScript-specific configuration and project-local customizations.
|
|
10
|
+
* Do not modify this file directly - use jest.config.local.ts for project-specific settings.
|
|
11
|
+
*
|
|
12
|
+
* Inheritance chain:
|
|
13
|
+
* jest.config.ts (this file)
|
|
14
|
+
* └── jest.typescript.ts
|
|
15
|
+
* └── jest.base.ts
|
|
16
|
+
*
|
|
17
|
+
* @see https://jestjs.io/docs/configuration
|
|
18
|
+
* @module jest.config
|
|
19
|
+
*/
|
|
20
|
+
import { mergeConfigs, mergeThresholds } from "./jest.base.ts";
|
|
21
|
+
import {
|
|
22
|
+
defaultThresholds,
|
|
23
|
+
getTypescriptJestConfig,
|
|
24
|
+
} from "./jest.typescript.ts";
|
|
25
|
+
|
|
26
|
+
import localConfig from "./jest.config.local.ts";
|
|
27
|
+
import thresholdsOverrides from "./jest.thresholds.json" with { type: "json" };
|
|
28
|
+
|
|
29
|
+
const thresholds = mergeThresholds(defaultThresholds, thresholdsOverrides);
|
|
30
|
+
|
|
31
|
+
export default mergeConfigs(
|
|
32
|
+
getTypescriptJestConfig({ thresholds }),
|
|
33
|
+
localConfig
|
|
34
|
+
);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is managed by Lisa.
|
|
3
|
+
* Do not edit directly — changes will be overwritten on the next `lisa` run.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Jest Configuration - TypeScript Stack
|
|
8
|
+
*
|
|
9
|
+
* Provides TypeScript/Node-specific Jest configuration.
|
|
10
|
+
* Imports shared utilities from jest.base.ts.
|
|
11
|
+
* Stack-specific configs (expo, nestjs, cdk) should import and extend this.
|
|
12
|
+
*
|
|
13
|
+
* @see https://jestjs.io/docs/configuration
|
|
14
|
+
* @module jest.typescript
|
|
15
|
+
*/
|
|
16
|
+
import type { Config } from "jest";
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
defaultCoverageExclusions,
|
|
20
|
+
defaultThresholds,
|
|
21
|
+
mergeConfigs,
|
|
22
|
+
mergeThresholds,
|
|
23
|
+
} from "./jest.base.ts";
|
|
24
|
+
|
|
25
|
+
// Re-export base utilities for stack-specific configs to use
|
|
26
|
+
export {
|
|
27
|
+
defaultCoverageExclusions,
|
|
28
|
+
defaultThresholds,
|
|
29
|
+
mergeConfigs,
|
|
30
|
+
mergeThresholds,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Options for configuring the TypeScript Jest config factory.
|
|
35
|
+
*/
|
|
36
|
+
interface TypescriptJestOptions {
|
|
37
|
+
/** Coverage thresholds (merged defaults + project overrides) */
|
|
38
|
+
readonly thresholds?: Config["coverageThreshold"];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates a Jest configuration for TypeScript/Node projects using ts-jest.
|
|
43
|
+
*
|
|
44
|
+
* @param options - Configuration options for threshold overrides
|
|
45
|
+
* @param options.thresholds - Coverage thresholds (merged defaults + project overrides)
|
|
46
|
+
* @returns Jest config object with ts-jest transform, ESM support, and coverage settings
|
|
47
|
+
* @remarks Uses ts-jest ESM preset for projects with "type": "module" in package.json.
|
|
48
|
+
* Projects needing CommonJS should override the preset in jest.config.local.ts.
|
|
49
|
+
*/
|
|
50
|
+
export const getTypescriptJestConfig = ({
|
|
51
|
+
thresholds = defaultThresholds,
|
|
52
|
+
}: TypescriptJestOptions = {}): Config => ({
|
|
53
|
+
preset: "ts-jest/presets/default-esm",
|
|
54
|
+
testEnvironment: "node",
|
|
55
|
+
testMatch: ["<rootDir>/tests/**/*.test.ts", "<rootDir>/src/**/*.test.ts"],
|
|
56
|
+
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
|
|
57
|
+
moduleNameMapper: {
|
|
58
|
+
"^(\\.{1,2}/.*)\\.js$": "$1",
|
|
59
|
+
},
|
|
60
|
+
transform: {
|
|
61
|
+
"^.+\\.tsx?$": [
|
|
62
|
+
"ts-jest",
|
|
63
|
+
{
|
|
64
|
+
useESM: true,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
extensionsToTreatAsEsm: [".ts"],
|
|
69
|
+
collectCoverageFrom: ["src/**/*.ts", ...defaultCoverageExclusions],
|
|
70
|
+
coverageThreshold: thresholds,
|
|
71
|
+
testTimeout: 10000,
|
|
72
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"strict": true,
|
|
5
|
+
"skipLibCheck": true,
|
|
6
|
+
"forceConsistentCasingInFileNames": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"baseUrl": "./"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jest Configuration - Project-Local Customizations
|
|
3
|
+
*
|
|
4
|
+
* Add project-specific Jest settings here. This file is create-only,
|
|
5
|
+
* meaning Lisa will create it but never overwrite your customizations.
|
|
6
|
+
*
|
|
7
|
+
* Example:
|
|
8
|
+
* ```ts
|
|
9
|
+
* import type { Config } from "jest";
|
|
10
|
+
*
|
|
11
|
+
* const config: Config = {
|
|
12
|
+
* moduleNameMapper: {
|
|
13
|
+
* "^@/(.*)$": "<rootDir>/src/$1",
|
|
14
|
+
* },
|
|
15
|
+
* setupFiles: ["<rootDir>/jest.setup.ts"],
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* export default config;
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see https://jestjs.io/docs/configuration
|
|
22
|
+
* @module jest.config.local
|
|
23
|
+
*/
|
|
24
|
+
import type { Config } from "jest";
|
|
25
|
+
|
|
26
|
+
const config: Config = {
|
|
27
|
+
// Add project-specific settings here
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default config;
|