@oxc-angular-testing/jest 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Matt Lewis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ export declare function process(sourceText: string): {
2
+ code: string;
3
+ };
4
+ declare const _default: {
5
+ process: typeof process;
6
+ };
7
+ export default _default;
8
+ //# sourceMappingURL=html-transformer-cjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-transformer-cjs.d.ts","sourceRoot":"","sources":["../src/html-transformer-cjs.ts"],"names":[],"mappings":"AAGA,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAE5D;;;;AAGD,wBAA2B"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.process = process;
4
+ // CommonJS variant of the HTML transformer: imported `.html` files (component
5
+ // `templateUrl` targets, emitted as `require("./x.html")` in CJS mode) become a
6
+ // module whose `module.exports` is the raw template string.
7
+ function process(sourceText) {
8
+ return { code: `module.exports = ${JSON.stringify(sourceText)};` };
9
+ }
10
+ // jest unwraps the transformer module's default export.
11
+ exports.default = { process };
12
+ //# sourceMappingURL=html-transformer-cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-transformer-cjs.js","sourceRoot":"","sources":["../src/html-transformer-cjs.ts"],"names":[],"mappings":";;AAGA,0BAEC;AALD,8EAA8E;AAC9E,gFAAgF;AAChF,4DAA4D;AAC5D,SAAgB,OAAO,CAAC,UAAkB;IACxC,OAAO,EAAE,IAAI,EAAE,oBAAoB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;AACrE,CAAC;AAED,wDAAwD;AACxD,kBAAe,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare function process(sourceText: string): {
2
+ code: string;
3
+ };
4
+ declare const _default: {
5
+ process: typeof process;
6
+ };
7
+ export default _default;
8
+ //# sourceMappingURL=html-transformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-transformer.d.ts","sourceRoot":"","sources":["../src/html-transformer.ts"],"names":[],"mappings":"AAQA,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAE5D;;;;AAGD,wBAA2B"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.process = process;
4
+ // Transforms imported `.html` files (component `templateUrl` targets) into an
5
+ // ESM module exporting the raw template string. Pair with the main transformer
6
+ // in jest config (the ESM preset wires this up):
7
+ //
8
+ // transform: {
9
+ // '^.+\\.tsx?$': '@oxc-angular-testing/jest',
10
+ // '^.+\\.html$': '@oxc-angular-testing/jest/html-transformer',
11
+ // }
12
+ function process(sourceText) {
13
+ return { code: `export default ${JSON.stringify(sourceText)};` };
14
+ }
15
+ // jest unwraps the transformer module's default export.
16
+ exports.default = { process };
17
+ //# sourceMappingURL=html-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-transformer.js","sourceRoot":"","sources":["../src/html-transformer.ts"],"names":[],"mappings":";;AAQA,0BAEC;AAVD,8EAA8E;AAC9E,+EAA+E;AAC/E,iDAAiD;AACjD,EAAE;AACF,iBAAiB;AACjB,kDAAkD;AAClD,mEAAmE;AACnE,MAAM;AACN,SAAgB,OAAO,CAAC,UAAkB;IACxC,OAAO,EAAE,IAAI,EAAE,kBAAkB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;AACnE,CAAC;AAED,wDAAwD;AACxD,kBAAe,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { type TransformOptions } from '@oxc-angular-testing/transform';
2
+ export interface OxcAngularJestOptions {
3
+ /** `"auto"` (default), `"require"`, or `"import"`. */
4
+ importMode?: 'auto' | 'require' | 'import';
5
+ /** Whether the project's module kind is ESM (used when importMode is auto). */
6
+ esm?: boolean;
7
+ /** Always instrument for coverage (jest also enables this when collecting coverage). */
8
+ coverage?: boolean;
9
+ /** Path to a tsconfig to derive target / module / decorator flags from. */
10
+ tsconfig?: string;
11
+ /** Extra regex sources marking files as ESM dependencies to downlevel. */
12
+ processEsmModules?: string[];
13
+ /**
14
+ * Files whose path matches this regex are returned as a string module (their
15
+ * raw content) instead of being compiled — for component `templateUrl` HTML
16
+ * and inline SVG. Mirrors jest-preset-angular's `stringifyContentPathRegex`.
17
+ * Default: `\\.(html|svg)$`. Set to `null`/`''` to disable.
18
+ */
19
+ stringifyContentPathRegex?: string | null;
20
+ /** Override individual transform options forwarded to the Rust transform. */
21
+ transform?: Partial<TransformOptions>;
22
+ }
23
+ /** Minimal structural shape of a synchronous jest transformer. */
24
+ export interface JestSyncTransformer {
25
+ canInstrument: boolean;
26
+ getCacheKey(sourceText: string, sourcePath: string, options: {
27
+ instrument?: boolean;
28
+ }): string;
29
+ process(sourceText: string, sourcePath: string, options?: {
30
+ instrument?: boolean;
31
+ }): {
32
+ code: string;
33
+ map?: unknown;
34
+ };
35
+ }
36
+ /**
37
+ * Decide whether a file is an ESM dependency that should be downleveled to the
38
+ * runner's module format with the Angular/TS passes skipped — i.e. a `.mjs`
39
+ * file or anything under `node_modules` (e.g. `@angular/core`, which ships only
40
+ * ESM and must be converted to CommonJS for classic CJS jest). Additional regex
41
+ * sources can be supplied via `processEsmModules`.
42
+ *
43
+ * Mirrors jest-preset-angular's `processWithEsbuild` fast path, but uses our own
44
+ * oxc ESM→CJS transform instead of esbuild.
45
+ */
46
+ export declare function isEsmDependency(sourcePath: string, processEsmModules?: string[]): boolean;
47
+ /**
48
+ * Jest transformer factory. Wire up in jest config (or use `createCjsPreset` /
49
+ * `createEsmPreset` from `@oxc-angular-testing/jest/presets`):
50
+ *
51
+ * transform: { '^.+\\.(ts|js|mjs)$': ['@oxc-angular-testing/jest', { importMode: 'require' }] }
52
+ *
53
+ * Works under both classic CommonJS jest (`importMode: 'require'`; the default
54
+ * `'auto'` resolves to require for CJS) and native-ESM jest (`importMode:
55
+ * 'import'` + Node vm modules). CommonJS output matches TypeScript's
56
+ * `module: "commonjs"` + `esModuleInterop` emit. ESM-only dependencies
57
+ * (`.mjs` / `node_modules`) are downleveled to the runner's module format with
58
+ * the Angular passes skipped.
59
+ */
60
+ export declare function createTransformer(transformerOptions?: OxcAngularJestOptions): JestSyncTransformer;
61
+ declare const _default: {
62
+ createTransformer: typeof createTransformer;
63
+ isEsmDependency: typeof isEsmDependency;
64
+ };
65
+ export default _default;
66
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"m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"use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.isEsmDependency = isEsmDependency;
37
+ exports.createTransformer = createTransformer;
38
+ const crypto = __importStar(require("node:crypto"));
39
+ const transform_1 = require("@oxc-angular-testing/transform");
40
+ const tsconfig_1 = require("@oxc-angular-testing/transform/tsconfig");
41
+ const package_json_1 = require("@oxc-angular-testing/transform/package.json");
42
+ /**
43
+ * Decide whether a file is an ESM dependency that should be downleveled to the
44
+ * runner's module format with the Angular/TS passes skipped — i.e. a `.mjs`
45
+ * file or anything under `node_modules` (e.g. `@angular/core`, which ships only
46
+ * ESM and must be converted to CommonJS for classic CJS jest). Additional regex
47
+ * sources can be supplied via `processEsmModules`.
48
+ *
49
+ * Mirrors jest-preset-angular's `processWithEsbuild` fast path, but uses our own
50
+ * oxc ESM→CJS transform instead of esbuild.
51
+ */
52
+ function isEsmDependency(sourcePath, processEsmModules) {
53
+ if (sourcePath.endsWith('.mjs') || sourcePath.includes('/node_modules/')) {
54
+ return true;
55
+ }
56
+ if (Array.isArray(processEsmModules)) {
57
+ return processEsmModules.some((pattern) => new RegExp(pattern).test(sourcePath));
58
+ }
59
+ return false;
60
+ }
61
+ /**
62
+ * Jest transformer factory. Wire up in jest config (or use `createCjsPreset` /
63
+ * `createEsmPreset` from `@oxc-angular-testing/jest/presets`):
64
+ *
65
+ * transform: { '^.+\\.(ts|js|mjs)$': ['@oxc-angular-testing/jest', { importMode: 'require' }] }
66
+ *
67
+ * Works under both classic CommonJS jest (`importMode: 'require'`; the default
68
+ * `'auto'` resolves to require for CJS) and native-ESM jest (`importMode:
69
+ * 'import'` + Node vm modules). CommonJS output matches TypeScript's
70
+ * `module: "commonjs"` + `esModuleInterop` emit. ESM-only dependencies
71
+ * (`.mjs` / `node_modules`) are downleveled to the runner's module format with
72
+ * the Angular passes skipped.
73
+ */
74
+ function createTransformer(transformerOptions = {}) {
75
+ const derived = transformerOptions.tsconfig
76
+ ? (0, tsconfig_1.deriveTransformOptions)(transformerOptions.tsconfig)
77
+ : {};
78
+ const importMode = transformerOptions.importMode || derived.importMode || 'auto';
79
+ const esm = transformerOptions.esm ?? derived.esm ?? false;
80
+ // Resolve whether output modules are ESM (controls the stringified module form).
81
+ const esmOutput = importMode === 'import' ? true : importMode === 'require' ? false : esm;
82
+ // `null`/`''` disables stringification.
83
+ const stringifyPattern = transformerOptions.stringifyContentPathRegex === undefined
84
+ ? '\\.(html|svg)$'
85
+ : transformerOptions.stringifyContentPathRegex;
86
+ const stringifyRe = stringifyPattern ? new RegExp(stringifyPattern) : null;
87
+ return {
88
+ canInstrument: true,
89
+ // Include the native transform version so jest's transform cache is
90
+ // invalidated when the binding (and thus its output) changes.
91
+ getCacheKey(sourceText, sourcePath, options) {
92
+ return crypto
93
+ .createHash('sha1')
94
+ .update(package_json_1.version)
95
+ .update('\0')
96
+ .update(JSON.stringify(transformerOptions))
97
+ .update('\0')
98
+ .update(JSON.stringify(derived))
99
+ .update('\0')
100
+ .update(options?.instrument ? '1' : '0')
101
+ .update('\0')
102
+ .update(sourcePath)
103
+ .update('\0')
104
+ .update(sourceText)
105
+ .digest('hex');
106
+ },
107
+ process(sourceText, sourcePath, options) {
108
+ // Component templateUrl HTML / inline SVG: return the raw content as a
109
+ // string module rather than compiling it (which would parse `<svg>` etc.
110
+ // as code).
111
+ if (stringifyRe?.test(sourcePath)) {
112
+ const literal = JSON.stringify(sourceText);
113
+ return {
114
+ code: esmOutput ? `export default ${literal};` : `module.exports = ${literal};`,
115
+ };
116
+ }
117
+ const collectCoverage = Boolean(options?.instrument);
118
+ const isDep = isEsmDependency(sourcePath, transformerOptions.processEsmModules);
119
+ const opts = {
120
+ ...derived,
121
+ importMode,
122
+ esm,
123
+ coverage: collectCoverage || Boolean(transformerOptions.coverage),
124
+ // ESM deps are plain JS: only downlevel the module format, skip the
125
+ // Angular JIT passes (they'd be no-ops but cost a traversal).
126
+ ...(isDep ? { jitTransforms: false } : {}),
127
+ ...transformerOptions.transform,
128
+ };
129
+ const out = (0, transform_1.transform)(sourceText, sourcePath, opts);
130
+ if (out.errors && out.errors.length > 0) {
131
+ throw new Error(`@oxc-angular-testing/jest: ${out.errors.join('\n')}`);
132
+ }
133
+ return { code: out.code, map: out.map ? JSON.parse(out.map) : undefined };
134
+ },
135
+ };
136
+ }
137
+ // jest's transformer loader unwraps the module's default export
138
+ // (`interopRequireDefault(...).default`), so expose the factory as the default
139
+ // too (named exports remain for TypeScript consumers).
140
+ exports.default = { createTransformer, isEsmDependency };
141
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"m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Ae,GAAG,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACrD,MAAM,KAAK,GAAG,eAAe,CAAC,UAAU,EAAE,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;YAChF,MAAM,IAAI,GAAqB;gBAC7B,GAAG,OAAO;gBACV,UAAU;gBACV,GAAG;gBACH,QAAQ,EAAE,eAAe,IAAI,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC;gBACjE,oEAAoE;gBACpE,8DAA8D;gBAC9D,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1C,GAAG,kBAAkB,CAAC,SAAS;aAChC,CAAC;YACF,MAAM,GAAG,GAAG,IAAA,qBAAS,EAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;YACpD,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxC,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACzE,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;QAC5E,CAAC;KACF,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,+EAA+E;AAC/E,uDAAuD;AACvD,kBAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { OxcAngularJestOptions } from './index.js';
2
+ export interface JestPresetConfig {
3
+ moduleFileExtensions: string[];
4
+ transform: Record<string, string | [string, Record<string, unknown>]>;
5
+ transformIgnorePatterns: string[];
6
+ testEnvironment: string;
7
+ extensionsToTreatAsEsm?: string[];
8
+ }
9
+ /**
10
+ * Classic CommonJS jest. TypeScript and ESM-only `.mjs` / `node_modules`
11
+ * dependencies (e.g. `@angular/core`) are downleveled to CommonJS. Run *without*
12
+ * `--experimental-vm-modules` so jest loads the transformed `.mjs` as CommonJS.
13
+ */
14
+ export declare function createCjsPreset(transformerOptions?: OxcAngularJestOptions): JestPresetConfig;
15
+ /**
16
+ * Native-ESM jest (run with `NODE_OPTIONS=--experimental-vm-modules`).
17
+ * TypeScript is emitted as ESM; `.mjs` / `node_modules` are loaded natively.
18
+ */
19
+ export declare function createEsmPreset(transformerOptions?: OxcAngularJestOptions): JestPresetConfig;
20
+ //# sourceMappingURL=presets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAIxD,MAAM,WAAW,gBAAgB;IAC/B,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACtE,uBAAuB,EAAE,MAAM,EAAE,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,kBAAkB,GAAE,qBAA0B,GAC7C,gBAAgB,CAalB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,kBAAkB,GAAE,qBAA0B,GAC7C,gBAAgB,CAWlB"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ // Ready-made jest config presets, mirroring jest-preset-angular's
3
+ // createCjsPreset / createEsmPreset. Spread into your jest config:
4
+ //
5
+ // import { createCjsPreset } from '@oxc-angular-testing/jest/presets';
6
+ // export default { ...createCjsPreset({ tsconfig: './tsconfig.spec.json' }) };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.createCjsPreset = createCjsPreset;
9
+ exports.createEsmPreset = createEsmPreset;
10
+ const TRANSFORMER = '@oxc-angular-testing/jest';
11
+ /**
12
+ * Classic CommonJS jest. TypeScript and ESM-only `.mjs` / `node_modules`
13
+ * dependencies (e.g. `@angular/core`) are downleveled to CommonJS. Run *without*
14
+ * `--experimental-vm-modules` so jest loads the transformed `.mjs` as CommonJS.
15
+ */
16
+ function createCjsPreset(transformerOptions = {}) {
17
+ const opts = { importMode: 'require', esm: false, ...transformerOptions };
18
+ return {
19
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'mjs', 'html', 'svg', 'json'],
20
+ transform: {
21
+ // One transformer for code + content: `.html`/`.svg` are stringified
22
+ // (via stringifyContentPathRegex), the rest compiled.
23
+ '^.+\\.(ts|tsx|js|mjs|html|svg)$': [TRANSFORMER, opts],
24
+ },
25
+ // Transform `.mjs` files in node_modules (e.g. @angular/*), ignore the rest.
26
+ transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
27
+ testEnvironment: 'node',
28
+ };
29
+ }
30
+ /**
31
+ * Native-ESM jest (run with `NODE_OPTIONS=--experimental-vm-modules`).
32
+ * TypeScript is emitted as ESM; `.mjs` / `node_modules` are loaded natively.
33
+ */
34
+ function createEsmPreset(transformerOptions = {}) {
35
+ const opts = { importMode: 'import', esm: true, ...transformerOptions };
36
+ return {
37
+ moduleFileExtensions: ['ts', 'tsx', 'mjs', 'js', 'html', 'svg', 'json'],
38
+ extensionsToTreatAsEsm: ['.ts', '.tsx', '.html', '.svg'],
39
+ transform: {
40
+ '^.+\\.(ts|tsx|html|svg)$': [TRANSFORMER, opts],
41
+ },
42
+ transformIgnorePatterns: ['node_modules/(?!tslib)'],
43
+ testEnvironment: 'node',
44
+ };
45
+ }
46
+ //# sourceMappingURL=presets.js.map
@@ -0,0 +1 @@
1
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+1,58 @@
1
+ {
2
+ "name": "@oxc-angular-testing/jest",
3
+ "version": "0.0.1",
4
+ "description": "Jest transformer wiring up @oxc-angular-testing/transform for Angular unit tests.",
5
+ "license": "MIT",
6
+ "type": "commonjs",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./presets": {
15
+ "types": "./dist/presets.d.ts",
16
+ "default": "./dist/presets.js"
17
+ },
18
+ "./html-transformer": {
19
+ "types": "./dist/html-transformer.d.ts",
20
+ "default": "./dist/html-transformer.js"
21
+ },
22
+ "./html-transformer-cjs": {
23
+ "types": "./dist/html-transformer-cjs.d.ts",
24
+ "default": "./dist/html-transformer-cjs.js"
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/mattlewis92/oxc-angular-testing.git",
34
+ "directory": "packages/jest"
35
+ },
36
+ "engines": {
37
+ "node": "^20.19.0 || >=22.12.0"
38
+ },
39
+ "dependencies": {
40
+ "@oxc-angular-testing/transform": "0.0.1"
41
+ },
42
+ "peerDependencies": {
43
+ "jest": ">=29"
44
+ },
45
+ "devDependencies": {
46
+ "@oxc-project/runtime": "^0.134.0",
47
+ "cross-env": "^7.0.3",
48
+ "jest": "^30.0.0",
49
+ "typescript": "^5.6.0"
50
+ },
51
+ "scripts": {
52
+ "build": "tsc -p tsconfig.json",
53
+ "typecheck": "tsc -p tsconfig.json --noEmit",
54
+ "test": "pnpm run test:cjs && pnpm run test:esm",
55
+ "test:cjs": "jest --selectProjects cjs",
56
+ "test:esm": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --selectProjects esm"
57
+ }
58
+ }