@happy-dom/jest-environment 17.6.0 → 17.6.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/lib/index.js +17 -7
- package/lib/index.js.map +1 -1
- package/package.json +6 -10
- package/bin/build-lit-ts-config.cjs +0 -74
- package/bin/copy-package-json-for-lit.cjs +0 -42
- package/bin/copy-tsdef-for-lit.cjs +0 -46
- package/bin/transform-lit-require.cjs +0 -64
package/lib/index.js
CHANGED
@@ -16,13 +16,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
16
16
|
}) : function(o, v) {
|
17
17
|
o["default"] = v;
|
18
18
|
});
|
19
|
-
var __importStar = (this && this.__importStar) || function (
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
};
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
20
|
+
var ownKeys = function(o) {
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
22
|
+
var ar = [];
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
24
|
+
return ar;
|
25
|
+
};
|
26
|
+
return ownKeys(o);
|
27
|
+
};
|
28
|
+
return function (mod) {
|
29
|
+
if (mod && mod.__esModule) return mod;
|
30
|
+
var result = {};
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
32
|
+
__setModuleDefault(result, mod);
|
33
|
+
return result;
|
34
|
+
};
|
35
|
+
})();
|
26
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
27
37
|
const JestUtil = __importStar(require("jest-util"));
|
28
38
|
const jest_mock_1 = require("jest-mock");
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,6CAA6C
|
1
|
+
{"version":3,"file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G;IACI,SAAS,CAAC,MAAc;QAC9B,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACI,YAAY;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD;AAhKD,sCAgKC;AAED,SAAS,qBAAqB,CAAC,MAAe;IAC7C,OAAO,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,SAAS,CAAC;AACzE,CAAC;AAED,SAAS,qBAAqB,CAC7B,MAAe;IAEf,OAAO,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,SAAS,CAAC;AAC/E,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@happy-dom/jest-environment",
|
3
|
-
"version": "17.6.
|
3
|
+
"version": "17.6.2",
|
4
4
|
"license": "MIT",
|
5
5
|
"homepage": "https://github.com/capricorn86/happy-dom/tree/master/packages/jest-environment",
|
6
6
|
"repository": "https://github.com/capricorn86/happy-dom",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
"access": "public"
|
26
26
|
},
|
27
27
|
"scripts": {
|
28
|
-
"compile": "
|
28
|
+
"compile": "tsc",
|
29
29
|
"watch": "npm run compile && tsc -w --preserveWatchOutput",
|
30
30
|
"test": "jest",
|
31
31
|
"test:watch": "jest --watch",
|
@@ -50,7 +50,7 @@
|
|
50
50
|
"@jest/environment": "^29.4.0",
|
51
51
|
"@jest/fake-timers": "^29.4.0",
|
52
52
|
"@jest/types": "^29.4.0",
|
53
|
-
"happy-dom": "^17.6.
|
53
|
+
"happy-dom": "^17.6.2",
|
54
54
|
"jest-mock": "^29.4.0",
|
55
55
|
"jest-util": "^29.4.0"
|
56
56
|
},
|
@@ -66,7 +66,7 @@
|
|
66
66
|
"@testing-library/user-event": "^14.5.1",
|
67
67
|
"@vue/test-utils": "^2.4.6",
|
68
68
|
"@types/jest": "29.5.2",
|
69
|
-
"@types/node": "^
|
69
|
+
"@types/node": "^20.0.0",
|
70
70
|
"@types/react": "^18.2.0",
|
71
71
|
"@types/react-dom": "^18.2.0",
|
72
72
|
"@typescript-eslint/eslint-plugin": "^5.16.0",
|
@@ -75,20 +75,16 @@
|
|
75
75
|
"glob": "^7.2.0",
|
76
76
|
"jest": "^29.4.0",
|
77
77
|
"jquery": "^3.6.0",
|
78
|
-
"lit": "^2.2.1",
|
79
|
-
"lit-element": "^3.2.0",
|
80
|
-
"lit-html": "^2.2.1",
|
81
|
-
"prettier": "^2.6.0",
|
82
78
|
"react": "^18.2.0",
|
83
79
|
"react-dom": "^18.2.0",
|
84
80
|
"usehooks-ts": "^3.0.1",
|
85
81
|
"rxjs": "^6.5.3",
|
86
82
|
"ts-jest": "^29.1.1",
|
87
|
-
"typescript": "^5.
|
83
|
+
"typescript": "^5.8.3",
|
88
84
|
"vue": "^3.5.12",
|
89
85
|
"zone.js": "^0.10.3"
|
90
86
|
},
|
91
87
|
"engines": {
|
92
|
-
"node": ">=
|
88
|
+
"node": ">=20.0.0"
|
93
89
|
}
|
94
90
|
}
|
@@ -1,74 +0,0 @@
|
|
1
|
-
/* eslint-disable no-console*/
|
2
|
-
/* eslint-disable @typescript-eslint/no-var-requires*/
|
3
|
-
|
4
|
-
const Fs = require('fs');
|
5
|
-
const Path = require('path');
|
6
|
-
|
7
|
-
const LIBS = ['@lit/reactive-element', 'lit', 'lit-element', 'lit-html'];
|
8
|
-
|
9
|
-
function getTsConfig(lib) {
|
10
|
-
const split = require.resolve(lib).split('node_modules');
|
11
|
-
const modulePathSplit = split[1].split(Path.sep);
|
12
|
-
const modulePath = modulePathSplit[1].startsWith('@')
|
13
|
-
? modulePathSplit[1] + Path.sep + modulePathSplit[2]
|
14
|
-
: modulePathSplit[1];
|
15
|
-
const path = Path.join(split[0], 'node_modules', modulePath);
|
16
|
-
|
17
|
-
return {
|
18
|
-
compilerOptions: {
|
19
|
-
module: 'CommonJS',
|
20
|
-
sourceMap: false,
|
21
|
-
target: 'es2020',
|
22
|
-
preserveSymlinks: true,
|
23
|
-
preserveWatchOutput: true,
|
24
|
-
experimentalDecorators: true,
|
25
|
-
allowSyntheticDefaultImports: false,
|
26
|
-
allowJs: true,
|
27
|
-
checkJs: false,
|
28
|
-
skipLibCheck: true,
|
29
|
-
resolveJsonModule: true,
|
30
|
-
moduleResolution: 'node',
|
31
|
-
noResolve: true,
|
32
|
-
incremental: true,
|
33
|
-
tsBuildInfoFile: lib.replace('@', '').replace(/[/\\]/g, '-') + '-tsbuildinfo',
|
34
|
-
lib: ['es2015', 'es2016', 'es2017'],
|
35
|
-
outDir: '../lib/node_modules/' + lib,
|
36
|
-
baseUrl: '.',
|
37
|
-
removeComments: true,
|
38
|
-
rootDir: path
|
39
|
-
},
|
40
|
-
include: [path],
|
41
|
-
exclude: [path + '/src']
|
42
|
-
};
|
43
|
-
}
|
44
|
-
|
45
|
-
async function writeTsConfigFile(lib) {
|
46
|
-
await Fs.promises.writeFile(
|
47
|
-
Path.resolve(`tmp/tsconfig.${lib.replace('@', '').replace(/[/\\]/g, '-')}.json`),
|
48
|
-
JSON.stringify(getTsConfig(lib), null, 4)
|
49
|
-
);
|
50
|
-
}
|
51
|
-
|
52
|
-
async function createTmpDirectory() {
|
53
|
-
await Fs.promises.mkdir(Path.resolve('tmp'));
|
54
|
-
}
|
55
|
-
|
56
|
-
async function writeLibFiles() {
|
57
|
-
await Promise.all(LIBS.map((lib) => writeTsConfigFile(lib)));
|
58
|
-
}
|
59
|
-
|
60
|
-
async function main() {
|
61
|
-
try {
|
62
|
-
await Fs.promises.access(Path.resolve('tmp'));
|
63
|
-
} catch (error) {
|
64
|
-
await createTmpDirectory();
|
65
|
-
}
|
66
|
-
await writeLibFiles();
|
67
|
-
}
|
68
|
-
|
69
|
-
process.on('unhandledRejection', (reason) => {
|
70
|
-
console.error(reason);
|
71
|
-
process.exit(1);
|
72
|
-
});
|
73
|
-
|
74
|
-
main();
|
@@ -1,42 +0,0 @@
|
|
1
|
-
/* eslint-disable no-console*/
|
2
|
-
/* eslint-disable @typescript-eslint/no-var-requires*/
|
3
|
-
|
4
|
-
const Path = require('path');
|
5
|
-
const FS = require('fs');
|
6
|
-
|
7
|
-
const LIBS = ['@lit/reactive-element', 'lit', 'lit-element', 'lit-html'];
|
8
|
-
|
9
|
-
function getLibPath(lib) {
|
10
|
-
const split = require.resolve(lib).split('node_modules');
|
11
|
-
const modulePathSplit = split[1].split(Path.sep);
|
12
|
-
const modulePath = modulePathSplit[1].startsWith('@')
|
13
|
-
? modulePathSplit[1] + Path.sep + modulePathSplit[2]
|
14
|
-
: modulePathSplit[1];
|
15
|
-
|
16
|
-
return Path.join(split[0], 'node_modules', modulePath);
|
17
|
-
}
|
18
|
-
|
19
|
-
async function writePackageJson(from, to) {
|
20
|
-
const packageJson = require(from);
|
21
|
-
delete packageJson.type;
|
22
|
-
delete packageJson.exports;
|
23
|
-
await FS.promises.writeFile(to, JSON.stringify(packageJson, null, 4));
|
24
|
-
}
|
25
|
-
|
26
|
-
async function main() {
|
27
|
-
await Promise.all(
|
28
|
-
LIBS.map((lib) =>
|
29
|
-
writePackageJson(
|
30
|
-
Path.join(getLibPath(lib), 'package.json'),
|
31
|
-
Path.resolve(Path.join('lib', 'node_modules', lib, 'package.json'))
|
32
|
-
)
|
33
|
-
)
|
34
|
-
);
|
35
|
-
}
|
36
|
-
|
37
|
-
process.on('unhandledRejection', (reason) => {
|
38
|
-
console.error(reason);
|
39
|
-
process.exit(1);
|
40
|
-
});
|
41
|
-
|
42
|
-
main();
|
@@ -1,46 +0,0 @@
|
|
1
|
-
/* eslint-disable no-console*/
|
2
|
-
/* eslint-disable @typescript-eslint/no-var-requires*/
|
3
|
-
|
4
|
-
const Path = require('path');
|
5
|
-
const fsp = require('fs/promises');
|
6
|
-
|
7
|
-
const LIBS = ['@lit/reactive-element', 'lit', 'lit-element', 'lit-html'];
|
8
|
-
|
9
|
-
function getLibPath(lib) {
|
10
|
-
const split = require.resolve(lib).split('node_modules');
|
11
|
-
const modulePathSplit = split[1].split(Path.sep);
|
12
|
-
const modulePath = modulePathSplit[1].startsWith('@')
|
13
|
-
? modulePathSplit[1] + Path.sep + modulePathSplit[2]
|
14
|
-
: modulePathSplit[1];
|
15
|
-
|
16
|
-
return Path.join(split[0], 'node_modules', modulePath);
|
17
|
-
}
|
18
|
-
|
19
|
-
async function copyTsDefFiles(lib) {
|
20
|
-
const srcDir = getLibPath(lib);
|
21
|
-
const destDir = Path.resolve(Path.join('lib', 'node_modules', lib));
|
22
|
-
|
23
|
-
await fsp.mkdir(destDir, { recursive: true });
|
24
|
-
|
25
|
-
const files = await fsp.readdir(srcDir);
|
26
|
-
|
27
|
-
const tsDefFiles = files.filter((file) => file.endsWith('.d.ts'));
|
28
|
-
|
29
|
-
const copyPromises = tsDefFiles.map((file) => {
|
30
|
-
const srcFile = Path.join(srcDir, file);
|
31
|
-
const destFile = Path.join(destDir, file);
|
32
|
-
return fsp.copyFile(srcFile, destFile);
|
33
|
-
});
|
34
|
-
await Promise.all(copyPromises);
|
35
|
-
}
|
36
|
-
|
37
|
-
async function main() {
|
38
|
-
await Promise.all(LIBS.map((lib) => copyTsDefFiles(lib)));
|
39
|
-
}
|
40
|
-
|
41
|
-
process.on('unhandledRejection', (reason) => {
|
42
|
-
console.error(reason);
|
43
|
-
process.exit(1);
|
44
|
-
});
|
45
|
-
|
46
|
-
main();
|
@@ -1,64 +0,0 @@
|
|
1
|
-
/* eslint-disable no-console*/
|
2
|
-
/* eslint-disable @typescript-eslint/no-var-requires*/
|
3
|
-
|
4
|
-
const FS = require('fs');
|
5
|
-
const Path = require('path');
|
6
|
-
const Glob = require('glob');
|
7
|
-
|
8
|
-
const LIBS = ['@lit/reactive-element', 'lit', 'lit-element', 'lit-html'];
|
9
|
-
|
10
|
-
function getFiles(lib) {
|
11
|
-
return new Promise((resolve, reject) => {
|
12
|
-
Glob(
|
13
|
-
`${Path.resolve('./lib/node_modules/' + lib)}/**/*.js`,
|
14
|
-
{ nodir: true },
|
15
|
-
(error, files) => {
|
16
|
-
if (error) {
|
17
|
-
reject(error);
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
resolve(files);
|
21
|
-
}
|
22
|
-
);
|
23
|
-
});
|
24
|
-
}
|
25
|
-
|
26
|
-
async function transformFile(lib, file) {
|
27
|
-
const data = (await FS.promises.readFile(file)).toString();
|
28
|
-
const regexp = /require\(["']([^"']+)["']\)/gm;
|
29
|
-
const libDirectory = lib.split('/').length > 1 ? '../../' : '../';
|
30
|
-
let newData = data;
|
31
|
-
let match = null;
|
32
|
-
|
33
|
-
while ((match = regexp.exec(data))) {
|
34
|
-
for (const externalLib of LIBS) {
|
35
|
-
if (match[1].startsWith(externalLib)) {
|
36
|
-
newData = newData.replace(match[0], `require("${libDirectory}${match[1]}")`);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
if (data !== newData) {
|
42
|
-
await FS.promises.writeFile(file, newData);
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
async function transformLib(lib) {
|
47
|
-
const files = await getFiles(lib);
|
48
|
-
const promises = [];
|
49
|
-
for (const file of files) {
|
50
|
-
promises.push(transformFile(lib, file));
|
51
|
-
}
|
52
|
-
await Promise.all(promises);
|
53
|
-
}
|
54
|
-
|
55
|
-
async function main() {
|
56
|
-
await Promise.all(LIBS.map((lib) => transformLib(lib)));
|
57
|
-
}
|
58
|
-
|
59
|
-
process.on('unhandledRejection', (reason) => {
|
60
|
-
console.error(reason);
|
61
|
-
process.exit(1);
|
62
|
-
});
|
63
|
-
|
64
|
-
main();
|