@oxc-angular-testing/jest 0.0.1 → 0.0.2
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 +13 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -17
- package/dist/index.js.map +1 -1
- package/dist/presets.js +2 -2
- package/dist/presets.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type TransformOptions } from '@oxc-angular-testing/transform';
|
|
2
2
|
export interface OxcAngularJestOptions {
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Output module format: `"commonjs"` (default) or `"esm"`. Drives `templateUrl`
|
|
5
|
+
* (`require` vs top-level `import`) and the ESM→CommonJS rewrite. Derived from
|
|
6
|
+
* the tsconfig `module` when a `tsconfig` is given; the CJS/ESM presets set it.
|
|
7
|
+
*/
|
|
8
|
+
module?: 'commonjs' | 'esm';
|
|
7
9
|
/** Always instrument for coverage (jest also enables this when collecting coverage). */
|
|
8
10
|
coverage?: boolean;
|
|
9
11
|
/** Path to a tsconfig to derive target / module / decorator flags from. */
|
|
@@ -18,7 +20,7 @@ export interface OxcAngularJestOptions {
|
|
|
18
20
|
*/
|
|
19
21
|
stringifyContentPathRegex?: string | null;
|
|
20
22
|
/** Override individual transform options forwarded to the Rust transform. */
|
|
21
|
-
transform?: Partial<TransformOptions
|
|
23
|
+
transform?: Partial<Omit<TransformOptions, 'module'>>;
|
|
22
24
|
}
|
|
23
25
|
/** Minimal structural shape of a synchronous jest transformer. */
|
|
24
26
|
export interface JestSyncTransformer {
|
|
@@ -48,14 +50,13 @@ export declare function isEsmDependency(sourcePath: string, processEsmModules?:
|
|
|
48
50
|
* Jest transformer factory. Wire up in jest config (or use `createCjsPreset` /
|
|
49
51
|
* `createEsmPreset` from `@oxc-angular-testing/jest/presets`):
|
|
50
52
|
*
|
|
51
|
-
* transform: { '^.+\\.(ts|js|mjs)$': ['@oxc-angular-testing/jest', {
|
|
53
|
+
* transform: { '^.+\\.(ts|js|mjs)$': ['@oxc-angular-testing/jest', { module: 'commonjs' }] }
|
|
52
54
|
*
|
|
53
|
-
* Works under both classic CommonJS jest (`
|
|
54
|
-
* `'
|
|
55
|
-
* '
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* the Angular passes skipped.
|
|
55
|
+
* Works under both classic CommonJS jest (`module: 'commonjs'`, the default) and
|
|
56
|
+
* native-ESM jest (`module: 'esm'` + Node vm modules). CommonJS output matches
|
|
57
|
+
* TypeScript's `module: "commonjs"` + `esModuleInterop` emit. ESM-only
|
|
58
|
+
* dependencies (`.mjs` / `node_modules`) are downleveled to the runner's module
|
|
59
|
+
* format with the Angular passes skipped.
|
|
59
60
|
*/
|
|
60
61
|
export declare function createTransformer(transformerOptions?: OxcAngularJestOptions): JestSyncTransformer;
|
|
61
62
|
declare const _default: {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAIlF,MAAM,WAAW,qBAAqB;IACpC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAIlF,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;IAC7E,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC;CACvD;AAED,kEAAkE;AAClE,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,CACT,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAChC,MAAM,CAAC;IACV,OAAO,CACL,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GACjC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,iBAAiB,CAAC,EAAE,MAAM,EAAE,GAC3B,OAAO,CAQT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,kBAAkB,GAAE,qBAA0B,GAC7C,mBAAmB,CAgErB;;;;;AAKD,wBAAsD"}
|
package/dist/index.js
CHANGED
|
@@ -62,23 +62,21 @@ function isEsmDependency(sourcePath, processEsmModules) {
|
|
|
62
62
|
* Jest transformer factory. Wire up in jest config (or use `createCjsPreset` /
|
|
63
63
|
* `createEsmPreset` from `@oxc-angular-testing/jest/presets`):
|
|
64
64
|
*
|
|
65
|
-
* transform: { '^.+\\.(ts|js|mjs)$': ['@oxc-angular-testing/jest', {
|
|
65
|
+
* transform: { '^.+\\.(ts|js|mjs)$': ['@oxc-angular-testing/jest', { module: 'commonjs' }] }
|
|
66
66
|
*
|
|
67
|
-
* Works under both classic CommonJS jest (`
|
|
68
|
-
* `'
|
|
69
|
-
* '
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* the Angular passes skipped.
|
|
67
|
+
* Works under both classic CommonJS jest (`module: 'commonjs'`, the default) and
|
|
68
|
+
* native-ESM jest (`module: 'esm'` + Node vm modules). CommonJS output matches
|
|
69
|
+
* TypeScript's `module: "commonjs"` + `esModuleInterop` emit. ESM-only
|
|
70
|
+
* dependencies (`.mjs` / `node_modules`) are downleveled to the runner's module
|
|
71
|
+
* format with the Angular passes skipped.
|
|
73
72
|
*/
|
|
74
73
|
function createTransformer(transformerOptions = {}) {
|
|
75
74
|
const derived = transformerOptions.tsconfig
|
|
76
75
|
? (0, tsconfig_1.deriveTransformOptions)(transformerOptions.tsconfig)
|
|
77
76
|
: {};
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const esmOutput = importMode === 'import' ? true : importMode === 'require' ? false : esm;
|
|
77
|
+
const moduleKind = transformerOptions.module ?? derived.module ?? 'commonjs';
|
|
78
|
+
// ESM output controls the stringified content module form (export vs module.exports).
|
|
79
|
+
const esmOutput = moduleKind === 'esm';
|
|
82
80
|
// `null`/`''` disables stringification.
|
|
83
81
|
const stringifyPattern = transformerOptions.stringifyContentPathRegex === undefined
|
|
84
82
|
? '\\.(html|svg)$'
|
|
@@ -118,13 +116,14 @@ function createTransformer(transformerOptions = {}) {
|
|
|
118
116
|
const isDep = isEsmDependency(sourcePath, transformerOptions.processEsmModules);
|
|
119
117
|
const opts = {
|
|
120
118
|
...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
119
|
...transformerOptions.transform,
|
|
120
|
+
module: moduleKind,
|
|
121
|
+
coverage: collectCoverage || Boolean(transformerOptions.coverage),
|
|
122
|
+
// Hoist `jest.mock()` above imports for the user's test code (jest
|
|
123
|
+
// requires this). Deps are library code with no jest.mock + skip JIT.
|
|
124
|
+
...(isDep
|
|
125
|
+
? { jitTransforms: false, hoistJestMock: false }
|
|
126
|
+
: { hoistJestMock: true }),
|
|
128
127
|
};
|
|
129
128
|
const out = (0, transform_1.transform)(sourceText, sourcePath, opts);
|
|
130
129
|
if (out.errors && out.errors.length > 0) {
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,0CAWC;AAcD,8CAkEC;AAjJD,oDAAsC;AACtC,8DAAkF;AAClF,sEAAiF;AACjF,8EAA0F;AAyC1F;;;;;;;;;GASG;AACH,SAAgB,eAAe,CAC7B,UAAkB,EAClB,iBAA4B;IAE5B,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACrC,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,iBAAiB,CAC/B,qBAA4C,EAAE;IAE9C,MAAM,OAAO,GAAG,kBAAkB,CAAC,QAAQ;QACzC,CAAC,CAAC,IAAA,iCAAsB,EAAC,kBAAkB,CA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AC,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.js
CHANGED
|
@@ -14,7 +14,7 @@ const TRANSFORMER = '@oxc-angular-testing/jest';
|
|
|
14
14
|
* `--experimental-vm-modules` so jest loads the transformed `.mjs` as CommonJS.
|
|
15
15
|
*/
|
|
16
16
|
function createCjsPreset(transformerOptions = {}) {
|
|
17
|
-
const opts = {
|
|
17
|
+
const opts = { module: 'commonjs', ...transformerOptions };
|
|
18
18
|
return {
|
|
19
19
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'mjs', 'html', 'svg', 'json'],
|
|
20
20
|
transform: {
|
|
@@ -32,7 +32,7 @@ function createCjsPreset(transformerOptions = {}) {
|
|
|
32
32
|
* TypeScript is emitted as ESM; `.mjs` / `node_modules` are loaded natively.
|
|
33
33
|
*/
|
|
34
34
|
function createEsmPreset(transformerOptions = {}) {
|
|
35
|
-
const opts = {
|
|
35
|
+
const opts = { module: 'esm', ...transformerOptions };
|
|
36
36
|
return {
|
|
37
37
|
moduleFileExtensions: ['ts', 'tsx', 'mjs', 'js', 'html', 'svg', 'json'],
|
|
38
38
|
extensionsToTreatAsEsm: ['.ts', '.tsx', '.html', '.svg'],
|
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;;AAmBjF,0CAeC;AAMD,0CAaC;AAjDD,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAUhD;;;;GAIG;AACH,SAAgB,eAAe,CAC7B,qBAA4C,EAAE;IAE9C,MAAM,IAAI,GAAG,EAAE,
|
|
1
|
+
{"version":3,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-testing/jest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Jest transformer wiring up @oxc-angular-testing/transform for Angular unit tests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"node": "^20.19.0 || >=22.12.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@oxc-angular-testing/transform": "0.0.
|
|
40
|
+
"@oxc-angular-testing/transform": "0.0.2"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"jest": ">=29"
|