@o3r/testing 14.0.0-prerelease.9 → 14.0.0-rc.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/testing",
|
|
3
|
-
"version": "14.0.0-
|
|
3
|
+
"version": "14.0.0-rc.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -99,10 +99,10 @@
|
|
|
99
99
|
"@material/slider": "^14.0.0",
|
|
100
100
|
"@ngrx/store": "^21.0.0",
|
|
101
101
|
"@ngx-translate/core": "^15.0.0 || ~16.0.4",
|
|
102
|
-
"@o3r/core": "~14.0.0-
|
|
103
|
-
"@o3r/eslint-config": "~14.0.0-
|
|
104
|
-
"@o3r/localization": "~14.0.0-
|
|
105
|
-
"@o3r/schematics": "~14.0.0-
|
|
102
|
+
"@o3r/core": "~14.0.0-rc.2",
|
|
103
|
+
"@o3r/eslint-config": "~14.0.0-rc.2",
|
|
104
|
+
"@o3r/localization": "~14.0.0-rc.2",
|
|
105
|
+
"@o3r/schematics": "~14.0.0-rc.2",
|
|
106
106
|
"@playwright/test": "^1.49.0",
|
|
107
107
|
"@schematics/angular": "^21.0.0",
|
|
108
108
|
"eslint": "~9.39.0",
|
|
@@ -170,9 +170,8 @@
|
|
|
170
170
|
}
|
|
171
171
|
},
|
|
172
172
|
"dependencies": {
|
|
173
|
-
"@o3r/schematics": "~14.0.0-
|
|
173
|
+
"@o3r/schematics": "~14.0.0-rc.2",
|
|
174
174
|
"esbuild": "~0.25.1",
|
|
175
|
-
"module-from-string": "^3.2.0",
|
|
176
175
|
"tslib": "^2.6.2"
|
|
177
176
|
},
|
|
178
177
|
"devDependencies": {
|
|
@@ -197,11 +196,11 @@
|
|
|
197
196
|
"@ngx-translate/core": "~16.0.4",
|
|
198
197
|
"@nx/eslint-plugin": "~22.3.3",
|
|
199
198
|
"@nx/jest": "~22.3.3",
|
|
200
|
-
"@o3r/build-helpers": "~14.0.0-
|
|
201
|
-
"@o3r/core": "~14.0.0-
|
|
202
|
-
"@o3r/eslint-plugin": "~14.0.0-
|
|
203
|
-
"@o3r/localization": "~14.0.0-
|
|
204
|
-
"@o3r/test-helpers": "~14.0.0-
|
|
199
|
+
"@o3r/build-helpers": "~14.0.0-rc.2",
|
|
200
|
+
"@o3r/core": "~14.0.0-rc.2",
|
|
201
|
+
"@o3r/eslint-plugin": "~14.0.0-rc.2",
|
|
202
|
+
"@o3r/localization": "~14.0.0-rc.2",
|
|
203
|
+
"@o3r/test-helpers": "~14.0.0-rc.2",
|
|
205
204
|
"@playwright/test": "~1.57.0",
|
|
206
205
|
"@schematics/angular": "~21.0.2",
|
|
207
206
|
"@standard-schema/spec": "~1.0.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-replacement.d.ts","sourceRoot":"","sources":["../../../src/tools/path-replacement/path-replacement.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"path-replacement.d.ts","sourceRoot":"","sources":["../../../src/tools/path-replacement/path-replacement.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,gBAAgB,EAEjB,MAAM,SAAS,CAAC;AA0DjB;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,aAAa,GAAE,YAA2B,EAAE,sBAAsB,GAAE,gBAAqB,QA8CnH"}
|
|
@@ -4,8 +4,60 @@ exports.adjustPath = adjustPath;
|
|
|
4
4
|
const fs = require("node:fs");
|
|
5
5
|
const node_module_1 = require("node:module");
|
|
6
6
|
const path = require("node:path");
|
|
7
|
+
const node_vm_1 = require("node:vm");
|
|
7
8
|
const esbuild_1 = require("esbuild");
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Get the global variables of the current process
|
|
11
|
+
* @returns The global variables of the current process
|
|
12
|
+
*/
|
|
13
|
+
function getNodeGlobals() {
|
|
14
|
+
const globals = Object.create(null);
|
|
15
|
+
for (const key of Object.getOwnPropertyNames(globalThis)) {
|
|
16
|
+
try {
|
|
17
|
+
const value = globalThis[key];
|
|
18
|
+
try {
|
|
19
|
+
globals[key] = structuredClone(value);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// Non-cloneable values (functions, symbols, etc.) - use reference
|
|
23
|
+
globals[key] = value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Some properties may throw when accessed (e.g., deprecated ones)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
globals.global = globalThis;
|
|
31
|
+
globals.globalThis = globalThis;
|
|
32
|
+
return globals;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Load a CommonJS module from a string.
|
|
36
|
+
* @param code The module code to execute
|
|
37
|
+
* @param dirname The directory to use as the module's dirname
|
|
38
|
+
*/
|
|
39
|
+
function requireFromString(code, dirname) {
|
|
40
|
+
const filename = path.join(dirname, '_virtual.js');
|
|
41
|
+
const mainRequire = require.main;
|
|
42
|
+
const tempModule = new node_module_1.Module(filename, mainRequire);
|
|
43
|
+
tempModule.require = (0, node_module_1.createRequire)(filename);
|
|
44
|
+
tempModule.filename = filename;
|
|
45
|
+
tempModule.paths = mainRequire?.paths ?? [];
|
|
46
|
+
const context = (0, node_vm_1.createContext)({
|
|
47
|
+
...getNodeGlobals(),
|
|
48
|
+
module: tempModule,
|
|
49
|
+
exports: tempModule.exports,
|
|
50
|
+
require: tempModule.require.bind(tempModule),
|
|
51
|
+
__dirname: dirname,
|
|
52
|
+
__filename: filename
|
|
53
|
+
});
|
|
54
|
+
const script = new node_vm_1.Script(code, {
|
|
55
|
+
filename
|
|
56
|
+
});
|
|
57
|
+
script.runInContext(context);
|
|
58
|
+
tempModule.loaded = true;
|
|
59
|
+
return tempModule.exports;
|
|
60
|
+
}
|
|
9
61
|
/**
|
|
10
62
|
* Switch to the needed implementation of core testing, when running e2e tests
|
|
11
63
|
* transforms ESM into CJS when needed
|
|
@@ -13,7 +65,7 @@ const module_from_string_1 = require("module-from-string");
|
|
|
13
65
|
* @param customTransformOptions
|
|
14
66
|
*/
|
|
15
67
|
function adjustPath(frameworkName = 'playwright', customTransformOptions = {}) {
|
|
16
|
-
const modulesCache =
|
|
68
|
+
const modulesCache = Object.create(null);
|
|
17
69
|
// eslint-disable-next-line @typescript-eslint/unbound-method -- No need to bind the method, we are using `apply`
|
|
18
70
|
const originalRequire = node_module_1.Module.prototype.require;
|
|
19
71
|
const regex = new RegExp(`@o3r/testing/core(?!/${frameworkName})(.*)`);
|
|
@@ -46,10 +98,7 @@ function adjustPath(frameworkName = 'playwright', customTransformOptions = {}) {
|
|
|
46
98
|
* no compiler facade in a global scope.
|
|
47
99
|
*/
|
|
48
100
|
try {
|
|
49
|
-
modulesCache[filePath] =
|
|
50
|
-
dirname: path.dirname(filePath),
|
|
51
|
-
useCurrentGlobal: true
|
|
52
|
-
});
|
|
101
|
+
modulesCache[filePath] = requireFromString(trans.code, path.dirname(filePath));
|
|
53
102
|
}
|
|
54
103
|
catch (ex) {
|
|
55
104
|
// eslint-disable-next-line no-console -- no other logger available
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-replacement.js","sourceRoot":"","sources":["../../../src/tools/path-replacement/path-replacement.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"path-replacement.js","sourceRoot":"","sources":["../../../src/tools/path-replacement/path-replacement.ts"],"names":[],"mappings":";;AA6EA,gCA8CC;AA3HD,8BAA8B;AAC9B,6CAGqB;AACrB,kCAAkC;AAClC,qCAGiB;AACjB,qCAGiB;AAEjB;;;GAGG;AACH,SAAS,cAAc;IACrB,MAAM,OAAO,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE7D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,CAAC;QACzD,IAAI,CAAC;YACH,MAAM,KAAK,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AA0C;gBAC1C,MAAM,KAAK,GAAG,IAAA,uBAAa,EAAC,WAAW,CAAC,QAAQ,EAAE,EAAE;oBAClD,MAAM,EAAE,IAAI;oBACZ,MAAM,EAAE,KAAK;oBACb,MAAM,EAAE,QAAQ;oBAChB,cAAc,EAAE,IAAI;oBACpB,UAAU,EAAE,GAAG;oBACf,GAAG,sBAAsB;iBAC1B,CAAC,CAAC;gBAEH;;;;;;mBAMG;gBACH,IAAI,CAAC;oBACH,YAAY,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACjF,CAAC;gBAAC,OAAO,EAAE,EAAE,CAAC;oBACZ,mEAAmE;oBACnE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACpB,CAAC;YACH,CAAC;YAED,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;IACH,CAAmB,CAAC;AACtB,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport {\n createRequire,\n Module,\n} from 'node:module';\nimport * as path from 'node:path';\nimport {\n createContext,\n Script,\n} from 'node:vm';\nimport {\n TransformOptions,\n transformSync,\n} from 'esbuild';\n\n/**\n * Get the global variables of the current process\n * @returns The global variables of the current process\n */\nfunction getNodeGlobals(): Record<string, unknown> {\n const globals: Record<string, unknown> = Object.create(null);\n\n for (const key of Object.getOwnPropertyNames(globalThis)) {\n try {\n const value = (globalThis as Record<string, unknown>)[key];\n try {\n globals[key] = structuredClone(value);\n } catch {\n // Non-cloneable values (functions, symbols, etc.) - use reference\n globals[key] = value;\n }\n } catch {\n // Some properties may throw when accessed (e.g., deprecated ones)\n }\n }\n\n globals.global = globalThis;\n globals.globalThis = globalThis;\n\n return globals;\n}\n\n/**\n * Load a CommonJS module from a string.\n * @param code The module code to execute\n * @param dirname The directory to use as the module's dirname\n */\nfunction requireFromString(code: string, dirname: string): string {\n const filename = path.join(dirname, '_virtual.js');\n const mainRequire = require.main;\n const tempModule = new Module(filename, mainRequire);\n tempModule.require = createRequire(filename);\n tempModule.filename = filename;\n tempModule.paths = mainRequire?.paths ?? [];\n const context = createContext({\n ...getNodeGlobals(),\n module: tempModule,\n exports: tempModule.exports,\n require: tempModule.require.bind(tempModule),\n __dirname: dirname,\n __filename: filename\n });\n\n const script = new Script(code, {\n filename\n });\n script.runInContext(context);\n tempModule.loaded = true;\n return tempModule.exports;\n}\n\n/**\n * Switch to the needed implementation of core testing, when running e2e tests\n * transforms ESM into CJS when needed\n * @param frameworkName Name of the framework used for e2e testing (playwright)\n * @param customTransformOptions\n */\nexport function adjustPath(frameworkName: 'playwright' = 'playwright', customTransformOptions: TransformOptions = {}) {\n const modulesCache: Record<string, unknown> = Object.create(null) as Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/unbound-method -- No need to bind the method, we are using `apply`\n const originalRequire = Module.prototype.require;\n const regex = new RegExp(`@o3r/testing/core(?!/${frameworkName})(.*)`);\n Module.prototype.require = function (this: NodeJS.Module, id: string) {\n const newId = id.replace(regex, `@o3r/testing/core/${frameworkName}$1`);\n\n try {\n return Reflect.apply(originalRequire, this, [newId]);\n } catch {\n const paths = ([] as string[])\n .concat(this.paths, this.paths.map((i) => i.replace(/[/\\\\]node_modules$/, '')));\n\n const filePath = require.resolve(newId, { paths });\n if (!modulesCache[filePath]) {\n const fileContent = fs.readFileSync(filePath);\n const cwd = path.resolve(process.cwd(), 'src');\n // we use ESBUILD to transform it into CJS\n const trans = transformSync(fileContent.toString(), {\n loader: 'js',\n format: 'cjs',\n target: 'es2016',\n sourcesContent: true,\n sourceRoot: cwd,\n ...customTransformOptions\n });\n\n /**\n * requireFromString will execute the file apart from just returning a module\n * It can throw an exception which will prevent stop the execution\n *\n * That main blocker includes IVY-compatible libraries which have\n * no compiler facade in a global scope.\n */\n try {\n modulesCache[filePath] = requireFromString(trans.code, path.dirname(filePath));\n } catch (ex) {\n // eslint-disable-next-line no-console -- no other logger available\n console.error(ex);\n }\n }\n\n return modulesCache[filePath];\n }\n } as NodeJS.Require;\n}\n"]}
|