@happy-dom/jest-environment 2.49.1 → 2.51.0
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/bin/build-lit-ts-config.js +2 -2
- package/bin/copy-package-json-for-lit.js +2 -2
- package/bin/copy-tsdef-for-lit.js +2 -2
- package/bin/transform-lit-require.js +2 -2
- package/lib/index.js +5 -3
- package/lib/index.js.map +1 -1
- package/package.json +31 -31
- package/src/index.ts +0 -3
- package/test/angular/AngularComponent.ts +1 -3
- package/test/javascript/JavaScript.test.ts +28 -0
- package/test/lit-element/LitElementComponent.ts +1 -3
- package/test/vue/Vue.test.ts +8 -6
@@ -54,7 +54,7 @@ async function createTmpDirectory() {
|
|
54
54
|
}
|
55
55
|
|
56
56
|
async function writeLibFiles() {
|
57
|
-
await Promise.all(LIBS.map(lib => writeTsConfigFile(lib)));
|
57
|
+
await Promise.all(LIBS.map((lib) => writeTsConfigFile(lib)));
|
58
58
|
}
|
59
59
|
|
60
60
|
async function main() {
|
@@ -66,7 +66,7 @@ async function main() {
|
|
66
66
|
await writeLibFiles();
|
67
67
|
}
|
68
68
|
|
69
|
-
process.on('unhandledRejection', reason => {
|
69
|
+
process.on('unhandledRejection', (reason) => {
|
70
70
|
console.error(reason);
|
71
71
|
process.exit(1);
|
72
72
|
});
|
@@ -25,7 +25,7 @@ async function writePackageJson(from, to) {
|
|
25
25
|
|
26
26
|
async function main() {
|
27
27
|
await Promise.all(
|
28
|
-
LIBS.map(lib =>
|
28
|
+
LIBS.map((lib) =>
|
29
29
|
writePackageJson(
|
30
30
|
Path.join(getLibPath(lib), 'package.json'),
|
31
31
|
Path.resolve(Path.join('lib', 'node_modules', lib, 'package.json'))
|
@@ -34,7 +34,7 @@ async function main() {
|
|
34
34
|
);
|
35
35
|
}
|
36
36
|
|
37
|
-
process.on('unhandledRejection', reason => {
|
37
|
+
process.on('unhandledRejection', (reason) => {
|
38
38
|
console.error(reason);
|
39
39
|
process.exit(1);
|
40
40
|
});
|
@@ -18,7 +18,7 @@ function getLibPath(lib) {
|
|
18
18
|
|
19
19
|
async function main() {
|
20
20
|
await Promise.all(
|
21
|
-
LIBS.map(lib =>
|
21
|
+
LIBS.map((lib) =>
|
22
22
|
CPY(
|
23
23
|
[Path.join(getLibPath(lib), '*.d.ts')],
|
24
24
|
Path.resolve(Path.join('lib', 'node_modules', lib))
|
@@ -27,7 +27,7 @@ async function main() {
|
|
27
27
|
);
|
28
28
|
}
|
29
29
|
|
30
|
-
process.on('unhandledRejection', reason => {
|
30
|
+
process.on('unhandledRejection', (reason) => {
|
31
31
|
console.error(reason);
|
32
32
|
process.exit(1);
|
33
33
|
});
|
@@ -53,10 +53,10 @@ async function transformLib(lib) {
|
|
53
53
|
}
|
54
54
|
|
55
55
|
async function main() {
|
56
|
-
await Promise.all(LIBS.map(lib => transformLib(lib)));
|
56
|
+
await Promise.all(LIBS.map((lib) => transformLib(lib)));
|
57
57
|
}
|
58
58
|
|
59
|
-
process.on('unhandledRejection', reason => {
|
59
|
+
process.on('unhandledRejection', (reason) => {
|
60
60
|
console.error(reason);
|
61
61
|
process.exit(1);
|
62
62
|
});
|
package/lib/index.js
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
/* eslint-disable filenames/match-exported */
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
4
4
|
if (k2 === undefined) k2 = k;
|
5
|
-
Object.
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
8
|
+
}
|
9
|
+
Object.defineProperty(o, k2, desc);
|
6
10
|
}) : (function(o, m, k, k2) {
|
7
11
|
if (k2 === undefined) k2 = k;
|
8
12
|
o[k2] = m[k];
|
@@ -81,8 +85,6 @@ var HappyDOMEnvironment = /** @class */ (function () {
|
|
81
85
|
this.global = this.window;
|
82
86
|
this.moduleMocker = new jest_mock_1.ModuleMocker(this.window);
|
83
87
|
vm_1.default.createContext(this.global);
|
84
|
-
// Functions are not an instanceof the "Function" class in the VM context, so therefore we set it to the used "Function" class.
|
85
|
-
vm_1.default.runInContext('window.Function = (() => {}).constructor;', this.global);
|
86
88
|
// Node's error-message stack size is limited to 10, but it's pretty useful to see more than that when a test fails.
|
87
89
|
this.global.Error.stackTraceLimit = 100;
|
88
90
|
// TODO: Remove this ASAP as it currently causes tests to run really slow.
|
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":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,6CAA6C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,0CAAoB;AACpB,kDAAsC;AACtC,uCAAyC;AACzC,iDAAuE;AAEvE,uCAAmC;AAInC;;GAEG;AACH;IAOC;;;;;OAKG;IACH,6BAAY,MAA4B,EAAE,OAA4B;QAZ/D,eAAU,GAA6B,IAAI,CAAC;QAC5C,qBAAgB,GAAqB,IAAI,CAAC;QAC1C,WAAM,GAAG,IAAI,kBAAM,EAAE,CAAC;QACtB,WAAM,GAA2C,IAAI,CAAC,MAAO,CAAC;QAC9D,iBAAY,GAAiB,IAAI,wBAAY,CAA8B,IAAI,CAAC,MAAO,CAAC,CAAC;QAS/F,YAAE,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE9B,oHAAoH;QACpH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC;QAExC,0EAA0E;QAC1E,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QAE5B,6BAA6B;QAC7B,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IA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GAAhB,UAAiB,MAAc;QAC9B,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACI,0CAAY,GAAnB;QACC,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IACF,0BAAC;AAAD,CAAC,AAzFD,IAyFC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@happy-dom/jest-environment",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.51.0",
|
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",
|
@@ -50,12 +50,12 @@
|
|
50
50
|
"testEnvironment": "./lib"
|
51
51
|
},
|
52
52
|
"dependencies": {
|
53
|
-
"@jest/environment": "^27.
|
54
|
-
"@jest/fake-timers": "^27.
|
55
|
-
"@jest/types": "^27.
|
56
|
-
"happy-dom": "^2.
|
57
|
-
"jest-mock": "^27.
|
58
|
-
"jest-util": "^27.
|
53
|
+
"@jest/environment": "^27.5.1",
|
54
|
+
"@jest/fake-timers": "^27.5.1",
|
55
|
+
"@jest/types": "^27.5.1",
|
56
|
+
"happy-dom": "^2.51.0",
|
57
|
+
"jest-mock": "^27.5.1",
|
58
|
+
"jest-util": "^27.5.1"
|
59
59
|
},
|
60
60
|
"devDependencies": {
|
61
61
|
"@angular/common": "^10.0.7",
|
@@ -63,33 +63,33 @@
|
|
63
63
|
"@angular/core": "^10.0.7",
|
64
64
|
"@angular/platform-browser": "^10.0.7",
|
65
65
|
"@angular/platform-browser-dynamic": "^10.0.7",
|
66
|
-
"@lit/reactive-element": "^1.
|
67
|
-
"@types/jest": "^
|
66
|
+
"@lit/reactive-element": "^1.3.1",
|
67
|
+
"@types/jest": "^27.4.1",
|
68
68
|
"@types/node": "^15.6.0",
|
69
|
-
"@typescript-eslint/eslint-plugin": "^
|
70
|
-
"@typescript-eslint/parser": "^
|
69
|
+
"@typescript-eslint/eslint-plugin": "^5.16.0",
|
70
|
+
"@typescript-eslint/parser": "^5.16.0",
|
71
71
|
"cpy": "^8.1.2",
|
72
|
-
"eslint": "^
|
73
|
-
"eslint-config-prettier": "^
|
72
|
+
"eslint": "^8.11.0",
|
73
|
+
"eslint-config-prettier": "^8.5.0",
|
74
74
|
"eslint-plugin-filenames": "^1.3.2",
|
75
|
-
"eslint-plugin-import": "^2.
|
76
|
-
"eslint-plugin-jest": "^
|
77
|
-
"eslint-plugin-jsdoc": "^
|
78
|
-
"eslint-plugin-json": "^
|
79
|
-
"eslint-plugin-prettier": "^
|
80
|
-
"glob": "^7.
|
81
|
-
"jest": "^27.
|
82
|
-
"jquery": "^3.
|
83
|
-
"lit": "^2.
|
84
|
-
"lit-element": "^3.
|
85
|
-
"lit-html": "^2.
|
86
|
-
"prettier": "^
|
87
|
-
"react": "^
|
88
|
-
"react-dom": "^
|
89
|
-
"ts-jest": "^27.
|
90
|
-
"typescript": "^4.2
|
91
|
-
"vue": "^2.
|
75
|
+
"eslint-plugin-import": "^2.25.4",
|
76
|
+
"eslint-plugin-jest": "^26.1.2",
|
77
|
+
"eslint-plugin-jsdoc": "^38.0.6",
|
78
|
+
"eslint-plugin-json": "^3.1.0",
|
79
|
+
"eslint-plugin-prettier": "^4.0.0",
|
80
|
+
"glob": "^7.2.0",
|
81
|
+
"jest": "^27.5.1",
|
82
|
+
"jquery": "^3.6.0",
|
83
|
+
"lit": "^2.2.1",
|
84
|
+
"lit-element": "^3.2.0",
|
85
|
+
"lit-html": "^2.2.1",
|
86
|
+
"prettier": "^2.6.0",
|
87
|
+
"react": "^17.0.2",
|
88
|
+
"react-dom": "^17.0.2",
|
89
|
+
"ts-jest": "^27.1.3",
|
90
|
+
"typescript": "^4.6.2",
|
91
|
+
"vue": "^3.2.31",
|
92
92
|
"zone.js": "^0.10.3"
|
93
93
|
},
|
94
|
-
"gitHead": "
|
94
|
+
"gitHead": "b02716daf82e29b7cf7fc25e7d133e09f4dfcf16"
|
95
95
|
}
|
package/src/index.ts
CHANGED
@@ -28,9 +28,6 @@ export default class HappyDOMEnvironment implements JestEnvironment {
|
|
28
28
|
constructor(config: Config.ProjectConfig, options?: EnvironmentContext) {
|
29
29
|
VM.createContext(this.global);
|
30
30
|
|
31
|
-
// Functions are not an instanceof the "Function" class in the VM context, so therefore we set it to the used "Function" class.
|
32
|
-
VM.runInContext('window.Function = (() => {}).constructor;', this.global);
|
33
|
-
|
34
31
|
// Node's error-message stack size is limited to 10, but it's pretty useful to see more than that when a test fails.
|
35
32
|
this.global.Error.stackTraceLimit = 100;
|
36
33
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
describe('JavaScript', () => {
|
2
|
+
it('Functions should have the constructor global.Function', () => {
|
3
|
+
expect((() => {}).constructor).toBe(Function);
|
4
|
+
});
|
5
|
+
|
6
|
+
it('Object should have the constructor global.Object', () => {
|
7
|
+
expect({}.constructor).toBe(Object);
|
8
|
+
});
|
9
|
+
|
10
|
+
it('Can perform a real fetch() to Github.com', async () => {
|
11
|
+
const response = await fetch(
|
12
|
+
'https://raw.githubusercontent.com/capricorn86/happy-dom/master/.gitignore'
|
13
|
+
);
|
14
|
+
|
15
|
+
expect(response.headers.get('content-type')).toBe('text/plain; charset=utf-8');
|
16
|
+
expect(response.ok).toBe(true);
|
17
|
+
expect(response.status).toBe(200);
|
18
|
+
expect(response.statusText).toBe('OK');
|
19
|
+
expect(response.url).toBe(
|
20
|
+
'https://raw.githubusercontent.com/capricorn86/happy-dom/master/.gitignore'
|
21
|
+
);
|
22
|
+
expect(response.redirected).toBe(false);
|
23
|
+
|
24
|
+
const body = await response.text();
|
25
|
+
|
26
|
+
expect(body.includes('node_modules')).toBe(true);
|
27
|
+
});
|
28
|
+
});
|
@@ -19,8 +19,6 @@ export default class LitElementComponent extends LitElement {
|
|
19
19
|
* Renders the component.
|
20
20
|
*/
|
21
21
|
public render(): TemplateResult {
|
22
|
-
return html`
|
23
|
-
Some text <span>${this.prop1}</span>!
|
24
|
-
`;
|
22
|
+
return html` Some text <span>${this.prop1}</span>! `;
|
25
23
|
}
|
26
24
|
}
|
package/test/vue/Vue.test.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import { createApp } from 'vue';
|
2
2
|
|
3
3
|
describe('Vue', () => {
|
4
4
|
let appElement: Element;
|
@@ -15,12 +15,14 @@ describe('Vue', () => {
|
|
15
15
|
});
|
16
16
|
|
17
17
|
it('Tests integration.', () => {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
const app = createApp({
|
19
|
+
data() {
|
20
|
+
return {
|
21
|
+
message: 'Test'
|
22
|
+
};
|
22
23
|
}
|
23
24
|
});
|
24
|
-
|
25
|
+
app.mount('#app');
|
26
|
+
expect(document.body.innerHTML).toBe('<div id="app" data-v-app="">Test</div>');
|
25
27
|
});
|
26
28
|
});
|