@oxc-angular-testing/jest 0.0.9 → 0.0.11
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/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +94 -22
- package/dist/index.js.map +1 -1
- package/dist/presets.d.ts +9 -0
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +14 -2
- package/dist/presets.js.map +1 -1
- package/package.json +2 -10
- package/dist/html-transformer-cjs.d.ts +0 -8
- package/dist/html-transformer-cjs.d.ts.map +0 -1
- package/dist/html-transformer-cjs.js +0 -12
- package/dist/html-transformer-cjs.js.map +0 -1
- package/dist/html-transformer.d.ts +0 -8
- package/dist/html-transformer.d.ts.map +0 -1
- package/dist/html-transformer.js +0 -17
- package/dist/html-transformer.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface OxcAngularJestOptions {
|
|
|
28
28
|
*/
|
|
29
29
|
stringifyContentPathRegex?: string | null;
|
|
30
30
|
/** Override individual transform options forwarded to the Rust transform. */
|
|
31
|
-
transform?: Partial<Omit<TransformOptions, 'module'>>;
|
|
31
|
+
transform?: Partial<Omit<TransformOptions, 'module' | 'coverage'>>;
|
|
32
32
|
}
|
|
33
33
|
/** Minimal structural shape of a synchronous jest transformer. */
|
|
34
34
|
export interface JestSyncTransformer {
|
|
@@ -41,13 +41,16 @@ export interface JestSyncTransformer {
|
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
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
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
44
|
+
* runner's module format with the Angular/TS passes skipped — i.e. a `.mjs` file,
|
|
45
|
+
* or a `.js` file under `node_modules` (e.g. `@angular/core`, which ships only ESM
|
|
46
|
+
* and must be converted to CommonJS for classic CJS jest). Additional regex sources
|
|
47
|
+
* can be supplied via `processEsmModules`.
|
|
48
48
|
*
|
|
49
|
-
* Mirrors jest-preset-angular's `processWithEsbuild` fast path
|
|
50
|
-
*
|
|
49
|
+
* Mirrors jest-preset-angular's `processWithEsbuild` fast path (jest-preset-angular
|
|
50
|
+
* 16: `**/*.mjs` globs, plus `filePath.includes('node_modules') && endsWith('.js')`),
|
|
51
|
+
* but uses our own oxc ESM→CJS transform instead of esbuild. The `node_modules`
|
|
52
|
+
* substring is intentionally unanchored, matching jest-preset-angular (also covers
|
|
53
|
+
* Windows `\node_modules\` and pnpm/Yarn-PnP layouts).
|
|
51
54
|
*/
|
|
52
55
|
export declare function isEsmDependency(sourcePath: string, processEsmModules?: string[]): boolean;
|
|
53
56
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AA2FlF,+EAA+E;AAC/E,UAAU,oBAAoB;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;IAC5B,wFAAwF;IACxF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,6EAA6E;IAG7E,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC;CACpE;AAED,kEAAkE;AAClE,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,CACT,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAC5B,MAAM,CAAC;IACV,OAAO,CACL,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,GAC7B;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACpC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,iBAAiB,CAAC,EAAE,MAAM,EAAE,GAC3B,OAAO,CAWT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,kBAAkB,GAAE,qBAA0B,GAC7C,mBAAmB,CAsGrB;;;;;AAKD,wBAAsD"}
|
package/dist/index.js
CHANGED
|
@@ -53,18 +53,83 @@ function expandRootDir(p, rootDir) {
|
|
|
53
53
|
}
|
|
54
54
|
return p;
|
|
55
55
|
}
|
|
56
|
+
// Verify, once per worker process, that the istanbul this project actually uses
|
|
57
|
+
// recognizes our emitted coverage schema marker. jest's `generateEmptyCoverage`
|
|
58
|
+
// calls `istanbul-lib-instrument`'s `readInitialCoverage` to report never-imported
|
|
59
|
+
// `collectCoverageFrom` files as 0%; if istanbul ever changes its schema, that call
|
|
60
|
+
// silently SKIPS our output (it doesn't throw) and those files vanish from the
|
|
61
|
+
// report. Round-trip a probe through the consumer's own istanbul and fail loudly if
|
|
62
|
+
// it isn't recognized.
|
|
63
|
+
let coverageSchemaChecked = false;
|
|
64
|
+
function verifyCoverageSchemaOnce() {
|
|
65
|
+
if (coverageSchemaChecked)
|
|
66
|
+
return;
|
|
67
|
+
coverageSchemaChecked = true;
|
|
68
|
+
// Resolve the istanbul-lib-instrument jest itself uses (relative to jest /
|
|
69
|
+
// @jest/reporters), falling back to this package's own resolution.
|
|
70
|
+
let readInitialCoverage;
|
|
71
|
+
let version = 'unknown';
|
|
72
|
+
const bases = [];
|
|
73
|
+
for (const pkg of ['jest', '@jest/reporters']) {
|
|
74
|
+
try {
|
|
75
|
+
bases.push(path.dirname(require.resolve(`${pkg}/package.json`)));
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
/* not installed under this name; try the next */
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
bases.push(__dirname);
|
|
82
|
+
for (const base of bases) {
|
|
83
|
+
try {
|
|
84
|
+
const ili = require(require.resolve('istanbul-lib-instrument', { paths: [base] }));
|
|
85
|
+
if (typeof ili.readInitialCoverage === 'function') {
|
|
86
|
+
readInitialCoverage = ili.readInitialCoverage.bind(ili);
|
|
87
|
+
try {
|
|
88
|
+
version = require(require.resolve('istanbul-lib-instrument/package.json', { paths: [base] })).version;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
/* keep 'unknown' */
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
/* try the next base */
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!readInitialCoverage) {
|
|
101
|
+
console.warn('@oxc-angular-testing/jest: could not resolve istanbul-lib-instrument to verify the ' +
|
|
102
|
+
'coverage schema marker; skipping the check. (Never-imported-file coverage relies on it.)');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const probe = (0, transform_1.transform)('const __oxc_probe__ = 1;\n', '__oxc_coverage_probe__.ts', {
|
|
106
|
+
coverage: true,
|
|
107
|
+
module: 'commonjs',
|
|
108
|
+
jitTransforms: false,
|
|
109
|
+
});
|
|
110
|
+
if (!readInitialCoverage(probe.code)) {
|
|
111
|
+
throw new Error(`@oxc-angular-testing/jest: your installed istanbul-lib-instrument@${version} does not ` +
|
|
112
|
+
"recognize this transform's coverage schema marker, so never-imported files would be " +
|
|
113
|
+
'silently dropped from coverage. This usually means istanbul changed its coverage schema — ' +
|
|
114
|
+
'please file an issue against @oxc-angular-testing.');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
56
117
|
/**
|
|
57
118
|
* Decide whether a file is an ESM dependency that should be downleveled to the
|
|
58
|
-
* runner's module format with the Angular/TS passes skipped — i.e. a `.mjs`
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
119
|
+
* runner's module format with the Angular/TS passes skipped — i.e. a `.mjs` file,
|
|
120
|
+
* or a `.js` file under `node_modules` (e.g. `@angular/core`, which ships only ESM
|
|
121
|
+
* and must be converted to CommonJS for classic CJS jest). Additional regex sources
|
|
122
|
+
* can be supplied via `processEsmModules`.
|
|
62
123
|
*
|
|
63
|
-
* Mirrors jest-preset-angular's `processWithEsbuild` fast path
|
|
64
|
-
*
|
|
124
|
+
* Mirrors jest-preset-angular's `processWithEsbuild` fast path (jest-preset-angular
|
|
125
|
+
* 16: `**/*.mjs` globs, plus `filePath.includes('node_modules') && endsWith('.js')`),
|
|
126
|
+
* but uses our own oxc ESM→CJS transform instead of esbuild. The `node_modules`
|
|
127
|
+
* substring is intentionally unanchored, matching jest-preset-angular (also covers
|
|
128
|
+
* Windows `\node_modules\` and pnpm/Yarn-PnP layouts).
|
|
65
129
|
*/
|
|
66
130
|
function isEsmDependency(sourcePath, processEsmModules) {
|
|
67
|
-
if (sourcePath.endsWith('.mjs') ||
|
|
131
|
+
if (sourcePath.endsWith('.mjs') ||
|
|
132
|
+
(sourcePath.includes('node_modules') && sourcePath.endsWith('.js'))) {
|
|
68
133
|
return true;
|
|
69
134
|
}
|
|
70
135
|
if (Array.isArray(processEsmModules)) {
|
|
@@ -90,26 +155,26 @@ function createTransformer(transformerOptions = {}) {
|
|
|
90
155
|
? '\\.(html|svg)$'
|
|
91
156
|
: transformerOptions.stringifyContentPathRegex;
|
|
92
157
|
const stringifyRe = stringifyPattern ? new RegExp(stringifyPattern) : null;
|
|
93
|
-
|
|
94
|
-
// expand a `<rootDir>/tsconfig.json` option is only available per-file on
|
|
95
|
-
// `options.config` — not at factory time. Deriving eagerly here would read the
|
|
96
|
-
// literal (unexpanded) path, find nothing, and derive NO options — silently
|
|
97
|
-
// dropping `target` (so oxc defaults to esnext: `async` stays native, etc.),
|
|
98
|
-
// `module`, and the decorator flags. Resolve lazily and memoize.
|
|
99
|
-
let resolved;
|
|
158
|
+
const resolvedByKey = new Map();
|
|
100
159
|
const resolve = (config) => {
|
|
101
|
-
|
|
102
|
-
|
|
160
|
+
const rootDir = config?.rootDir;
|
|
161
|
+
const base = rootDir ?? config?.cwd;
|
|
162
|
+
const tsconfigPath = transformerOptions.tsconfig
|
|
163
|
+
? expandRootDir(transformerOptions.tsconfig, rootDir)
|
|
164
|
+
: '';
|
|
165
|
+
const key = `${tsconfigPath}\0${base ?? ''}`;
|
|
166
|
+
const cached = resolvedByKey.get(key);
|
|
167
|
+
if (cached)
|
|
168
|
+
return cached;
|
|
103
169
|
let derived = {};
|
|
104
170
|
if (transformerOptions.tsconfig) {
|
|
105
|
-
|
|
106
|
-
const tsconfigPath = expandRootDir(transformerOptions.tsconfig, rootDir);
|
|
107
|
-
derived = (0, tsconfig_1.deriveTransformOptions)(tsconfigPath, rootDir ?? config?.cwd);
|
|
171
|
+
derived = (0, tsconfig_1.deriveTransformOptions)(tsconfigPath, base);
|
|
108
172
|
}
|
|
109
173
|
const moduleKind = transformerOptions.module ?? derived.module ?? 'commonjs';
|
|
110
174
|
// ESM output controls the stringified content module form (export vs module.exports).
|
|
111
|
-
|
|
112
|
-
|
|
175
|
+
const result = { derived, moduleKind, esmOutput: moduleKind === 'esm' };
|
|
176
|
+
resolvedByKey.set(key, result);
|
|
177
|
+
return result;
|
|
113
178
|
};
|
|
114
179
|
return {
|
|
115
180
|
canInstrument: true,
|
|
@@ -149,13 +214,20 @@ function createTransformer(transformerOptions = {}) {
|
|
|
149
214
|
...derived,
|
|
150
215
|
...transformerOptions.transform,
|
|
151
216
|
module: moduleKind,
|
|
152
|
-
|
|
217
|
+
// Coverage precedence (identical in the vitest plugin): an explicit
|
|
218
|
+
// top-level `coverage` option wins (true OR false); otherwise derive from
|
|
219
|
+
// the runner — here jest's per-file `instrument` signal. `coverage` is not
|
|
220
|
+
// settable via `transform` (excluded from its type), so there is no second,
|
|
221
|
+
// inconsistent knob.
|
|
222
|
+
coverage: transformerOptions.coverage ?? collectCoverage,
|
|
153
223
|
// Hoist `jest.mock()` above imports for the user's test code (jest
|
|
154
224
|
// requires this). Deps are library code with no jest.mock + skip JIT.
|
|
155
225
|
...(isDep
|
|
156
226
|
? { jitTransforms: false, hoistJestMock: false }
|
|
157
227
|
: { hoistJestMock: true }),
|
|
158
228
|
};
|
|
229
|
+
if (opts.coverage)
|
|
230
|
+
verifyCoverageSchemaOnce();
|
|
159
231
|
const out = (0, transform_1.transform)(sourceText, sourcePath, opts);
|
|
160
232
|
if (out.errors && out.errors.length > 0) {
|
|
161
233
|
throw new Error(`@oxc-angular-testing/jest: ${out.errors.join('\n')}`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyJA,0CAcC;AAcD,8CAwGC;AA7RD,oDAAsC;AACtC,gDAAkC;AAClC,8DAAkF;AAClF,sEAGiD;AACjD,8EAA0F;AAE1F;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,CAA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,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"}
|
package/dist/presets.d.ts
CHANGED
|
@@ -10,11 +10,20 @@ export interface JestPresetConfig {
|
|
|
10
10
|
* Classic CommonJS jest. TypeScript and ESM-only `.mjs` / `node_modules`
|
|
11
11
|
* dependencies (e.g. `@angular/core`) are downleveled to CommonJS. Run *without*
|
|
12
12
|
* `--experimental-vm-modules` so jest loads the transformed `.mjs` as CommonJS.
|
|
13
|
+
*
|
|
14
|
+
* The returned config is a starting point. `transformIgnorePatterns` only un-ignores
|
|
15
|
+
* the deps jest-preset-angular does by default (`.mjs` + `@angular/common/locales/*.js`);
|
|
16
|
+
* if you depend on an ESM-authored `.js` package in `node_modules`, extend
|
|
17
|
+
* `transformIgnorePatterns` (and, if needed, the `transform` map) yourself.
|
|
13
18
|
*/
|
|
14
19
|
export declare function createCjsPreset(transformerOptions?: OxcAngularJestOptions): JestPresetConfig;
|
|
15
20
|
/**
|
|
16
21
|
* Native-ESM jest (run with `NODE_OPTIONS=--experimental-vm-modules`).
|
|
17
22
|
* TypeScript is emitted as ESM; `.mjs` / `node_modules` are loaded natively.
|
|
23
|
+
*
|
|
24
|
+
* As with the CJS preset, `transformIgnorePatterns` only un-ignores `tslib` by
|
|
25
|
+
* default (matching jest-preset-angular); extend it for other node_modules deps that
|
|
26
|
+
* need transforming.
|
|
18
27
|
*/
|
|
19
28
|
export declare function createEsmPreset(transformerOptions?: OxcAngularJestOptions): JestPresetConfig;
|
|
20
29
|
//# sourceMappingURL=presets.d.ts.map
|
package/dist/presets.d.ts.map
CHANGED
|
@@ -1 +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
|
|
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;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,kBAAkB,GAAE,qBAA0B,GAC7C,gBAAgB,CAgBlB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,kBAAkB,GAAE,qBAA0B,GAC7C,gBAAgB,CAWlB"}
|
package/dist/presets.js
CHANGED
|
@@ -12,6 +12,11 @@ const TRANSFORMER = '@oxc-angular-testing/jest';
|
|
|
12
12
|
* Classic CommonJS jest. TypeScript and ESM-only `.mjs` / `node_modules`
|
|
13
13
|
* dependencies (e.g. `@angular/core`) are downleveled to CommonJS. Run *without*
|
|
14
14
|
* `--experimental-vm-modules` so jest loads the transformed `.mjs` as CommonJS.
|
|
15
|
+
*
|
|
16
|
+
* The returned config is a starting point. `transformIgnorePatterns` only un-ignores
|
|
17
|
+
* the deps jest-preset-angular does by default (`.mjs` + `@angular/common/locales/*.js`);
|
|
18
|
+
* if you depend on an ESM-authored `.js` package in `node_modules`, extend
|
|
19
|
+
* `transformIgnorePatterns` (and, if needed, the `transform` map) yourself.
|
|
15
20
|
*/
|
|
16
21
|
function createCjsPreset(transformerOptions = {}) {
|
|
17
22
|
const opts = { module: 'commonjs', ...transformerOptions };
|
|
@@ -22,14 +27,21 @@ function createCjsPreset(transformerOptions = {}) {
|
|
|
22
27
|
// (via stringifyContentPathRegex), the rest compiled (incl. React .tsx/.jsx).
|
|
23
28
|
'^.+\\.(ts|tsx|js|jsx|mjs|html|svg)$': [TRANSFORMER, opts],
|
|
24
29
|
},
|
|
25
|
-
// Transform `.mjs`
|
|
26
|
-
|
|
30
|
+
// Transform node_modules `.mjs` (e.g. @angular/*) + @angular/common locale `.js`,
|
|
31
|
+
// ignore the rest — matching jest-preset-angular's default un-ignore set.
|
|
32
|
+
transformIgnorePatterns: [
|
|
33
|
+
'node_modules/(?!(.*\\.mjs$|@angular/common/locales/.*\\.js$))',
|
|
34
|
+
],
|
|
27
35
|
testEnvironment: 'node',
|
|
28
36
|
};
|
|
29
37
|
}
|
|
30
38
|
/**
|
|
31
39
|
* Native-ESM jest (run with `NODE_OPTIONS=--experimental-vm-modules`).
|
|
32
40
|
* TypeScript is emitted as ESM; `.mjs` / `node_modules` are loaded natively.
|
|
41
|
+
*
|
|
42
|
+
* As with the CJS preset, `transformIgnorePatterns` only un-ignores `tslib` by
|
|
43
|
+
* default (matching jest-preset-angular); extend it for other node_modules deps that
|
|
44
|
+
* need transforming.
|
|
33
45
|
*/
|
|
34
46
|
function createEsmPreset(transformerOptions = {}) {
|
|
35
47
|
const opts = { module: 'esm', ...transformerOptions };
|
package/dist/presets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":";AAAA,kEAAkE;AAClE,mEAAmE;AACnE,EAAE;AACF,yEAAyE;AACzE,iFAAiF;;
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":";AAAA,kEAAkE;AAClE,mEAAmE;AACnE,EAAE;AACF,yEAAyE;AACzE,iFAAiF;;AAwBjF,0CAkBC;AAUD,0CAaC;AA7DD,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAUhD;;;;;;;;;GASG;AACH,SAAgB,eAAe,CAC7B,qBAA4C,EAAE;IAE9C,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAC3D,OAAO;QACL,oBAAoB,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;QAC9E,SAAS,EAAE;YACT,qEAAqE;YACrE,8EAA8E;YAC9E,qCAAqC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;SAC3D;QACD,kFAAkF;QAClF,0EAA0E;QAC1E,uBAAuB,EAAE;YACvB,+DAA+D;SAChE;QACD,eAAe,EAAE,MAAM;KACxB,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,eAAe,CAC7B,qBAA4C,EAAE;IAE9C,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,EAAE,CAAC;IACtD,OAAO;QACL,oBAAoB,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;QAC9E,sBAAsB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC;QAChE,SAAS,EAAE;YACT,8BAA8B,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;SACpD;QACD,uBAAuB,EAAE,CAAC,wBAAwB,CAAC;QACnD,eAAe,EAAE,MAAM;KACxB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxc-angular-testing/jest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Jest transformer wiring up @oxc-angular-testing/transform for Angular unit tests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -15,14 +15,6 @@
|
|
|
15
15
|
"types": "./dist/presets.d.ts",
|
|
16
16
|
"default": "./dist/presets.js"
|
|
17
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
18
|
"./package.json": "./package.json"
|
|
27
19
|
},
|
|
28
20
|
"files": [
|
|
@@ -37,7 +29,7 @@
|
|
|
37
29
|
"node": "^20.19.0 || >=22.12.0"
|
|
38
30
|
},
|
|
39
31
|
"dependencies": {
|
|
40
|
-
"@oxc-angular-testing/transform": "0.0.
|
|
32
|
+
"@oxc-angular-testing/transform": "0.0.11"
|
|
41
33
|
},
|
|
42
34
|
"peerDependencies": {
|
|
43
35
|
"jest": ">=29"
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/html-transformer.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|