jest-environment-jsdom 29.7.0 → 30.0.0-alpha.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/build/index.d.ts +12 -10
- package/build/index.js +49 -40
- package/build/index.mjs +4 -0
- package/package.json +13 -11
package/build/index.d.ts
CHANGED
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
+
|
|
7
8
|
/// <reference types="node" />
|
|
8
9
|
|
|
9
|
-
import
|
|
10
|
-
import type {EnvironmentContext} from '@jest/environment';
|
|
11
|
-
import type {Global} from '@jest/types';
|
|
12
|
-
import type {JestEnvironment} from '@jest/environment';
|
|
13
|
-
import type {JestEnvironmentConfig} from '@jest/environment';
|
|
10
|
+
import {Context} from 'vm';
|
|
14
11
|
import {JSDOM} from 'jsdom';
|
|
15
|
-
import {
|
|
16
|
-
|
|
12
|
+
import {
|
|
13
|
+
EnvironmentContext,
|
|
14
|
+
JestEnvironment,
|
|
15
|
+
JestEnvironmentConfig,
|
|
16
|
+
} from '@jest/environment';
|
|
17
|
+
import {LegacyFakeTimers, ModernFakeTimers} from '@jest/fake-timers';
|
|
18
|
+
import {Global as Global_2} from '@jest/types';
|
|
17
19
|
import {ModuleMocker} from 'jest-mock';
|
|
18
20
|
|
|
19
21
|
declare class JSDOMEnvironment implements JestEnvironment<number> {
|
|
@@ -23,8 +25,8 @@ declare class JSDOMEnvironment implements JestEnvironment<number> {
|
|
|
23
25
|
global: Win;
|
|
24
26
|
private errorEventListener;
|
|
25
27
|
moduleMocker: ModuleMocker | null;
|
|
26
|
-
customExportConditions: string
|
|
27
|
-
private _configuredExportConditions?;
|
|
28
|
+
customExportConditions: Array<string>;
|
|
29
|
+
private readonly _configuredExportConditions?;
|
|
28
30
|
constructor(config: JestEnvironmentConfig, context: EnvironmentContext);
|
|
29
31
|
setup(): Promise<void>;
|
|
30
32
|
teardown(): Promise<void>;
|
|
@@ -36,7 +38,7 @@ export default JSDOMEnvironment;
|
|
|
36
38
|
export declare const TestEnvironment: typeof JSDOMEnvironment;
|
|
37
39
|
|
|
38
40
|
declare type Win = Window &
|
|
39
|
-
|
|
41
|
+
Global_2.Global & {
|
|
40
42
|
Error: {
|
|
41
43
|
stackTraceLimit: number;
|
|
42
44
|
};
|
package/build/index.js
CHANGED
|
@@ -1,32 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* /**
|
|
3
|
+
* * Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
* *
|
|
5
|
+
* * This source code is licensed under the MIT license found in the
|
|
6
|
+
* * LICENSE file in the root directory of this source tree.
|
|
7
|
+
* * /
|
|
8
|
+
*/
|
|
9
|
+
/******/ (() => { // webpackBootstrap
|
|
10
|
+
/******/ "use strict";
|
|
11
|
+
var __webpack_exports__ = {};
|
|
12
|
+
// This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
|
|
13
|
+
(() => {
|
|
14
|
+
var exports = __webpack_exports__;
|
|
15
|
+
|
|
2
16
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
17
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
4
18
|
value: true
|
|
5
|
-
});
|
|
6
|
-
exports
|
|
19
|
+
}));
|
|
20
|
+
exports["default"] = exports.TestEnvironment = void 0;
|
|
7
21
|
function _jsdom() {
|
|
8
|
-
const data = require(
|
|
22
|
+
const data = require("jsdom");
|
|
9
23
|
_jsdom = function () {
|
|
10
24
|
return data;
|
|
11
25
|
};
|
|
12
26
|
return data;
|
|
13
27
|
}
|
|
14
28
|
function _fakeTimers() {
|
|
15
|
-
const data = require(
|
|
29
|
+
const data = require("@jest/fake-timers");
|
|
16
30
|
_fakeTimers = function () {
|
|
17
31
|
return data;
|
|
18
32
|
};
|
|
19
33
|
return data;
|
|
20
34
|
}
|
|
21
35
|
function _jestMock() {
|
|
22
|
-
const data = require(
|
|
36
|
+
const data = require("jest-mock");
|
|
23
37
|
_jestMock = function () {
|
|
24
38
|
return data;
|
|
25
39
|
};
|
|
26
40
|
return data;
|
|
27
41
|
}
|
|
28
42
|
function _jestUtil() {
|
|
29
|
-
const data = require(
|
|
43
|
+
const data = require("jest-util");
|
|
30
44
|
_jestUtil = function () {
|
|
31
45
|
return data;
|
|
32
46
|
};
|
|
@@ -54,7 +68,9 @@ class JSDOMEnvironment {
|
|
|
54
68
|
customExportConditions = ['browser'];
|
|
55
69
|
_configuredExportConditions;
|
|
56
70
|
constructor(config, context) {
|
|
57
|
-
const {
|
|
71
|
+
const {
|
|
72
|
+
projectConfig
|
|
73
|
+
} = config;
|
|
58
74
|
const virtualConsole = new (_jsdom().VirtualConsole)();
|
|
59
75
|
virtualConsole.sendTo(context.console, {
|
|
60
76
|
omitJSDOMErrors: true
|
|
@@ -62,30 +78,22 @@ class JSDOMEnvironment {
|
|
|
62
78
|
virtualConsole.on('jsdomError', error => {
|
|
63
79
|
context.console.error(error);
|
|
64
80
|
});
|
|
65
|
-
this.dom = new (_jsdom().JSDOM)(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
: undefined,
|
|
77
|
-
runScripts: 'dangerously',
|
|
78
|
-
url: 'http://localhost/',
|
|
79
|
-
virtualConsole,
|
|
80
|
-
...projectConfig.testEnvironmentOptions
|
|
81
|
-
}
|
|
82
|
-
);
|
|
83
|
-
const global = (this.global = this.dom.window);
|
|
81
|
+
this.dom = new (_jsdom().JSDOM)(typeof projectConfig.testEnvironmentOptions.html === 'string' ? projectConfig.testEnvironmentOptions.html : '<!DOCTYPE html>', {
|
|
82
|
+
pretendToBeVisual: true,
|
|
83
|
+
resources: typeof projectConfig.testEnvironmentOptions.userAgent === 'string' ? new (_jsdom().ResourceLoader)({
|
|
84
|
+
userAgent: projectConfig.testEnvironmentOptions.userAgent
|
|
85
|
+
}) : undefined,
|
|
86
|
+
runScripts: 'dangerously',
|
|
87
|
+
url: 'http://localhost/',
|
|
88
|
+
virtualConsole,
|
|
89
|
+
...projectConfig.testEnvironmentOptions
|
|
90
|
+
});
|
|
91
|
+
const global = this.global = this.dom.window;
|
|
84
92
|
if (global == null) {
|
|
85
93
|
throw new Error('JSDOM did not return a Window object');
|
|
86
94
|
}
|
|
87
95
|
|
|
88
|
-
//
|
|
96
|
+
// TODO: remove at some point - for "universal" code (code should use `globalThis`)
|
|
89
97
|
global.global = global;
|
|
90
98
|
|
|
91
99
|
// Node's error-message stack size is limited at 10, but it's pretty useful
|
|
@@ -122,16 +130,13 @@ class JSDOMEnvironment {
|
|
|
122
130
|
return originalRemoveListener.apply(this, args);
|
|
123
131
|
};
|
|
124
132
|
if ('customExportConditions' in projectConfig.testEnvironmentOptions) {
|
|
125
|
-
const {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
) {
|
|
133
|
+
const {
|
|
134
|
+
customExportConditions
|
|
135
|
+
} = projectConfig.testEnvironmentOptions;
|
|
136
|
+
if (Array.isArray(customExportConditions) && customExportConditions.every(isString)) {
|
|
130
137
|
this._configuredExportConditions = customExportConditions;
|
|
131
138
|
} else {
|
|
132
|
-
throw new Error(
|
|
133
|
-
'Custom export conditions specified but they are not an array of strings'
|
|
134
|
-
);
|
|
139
|
+
throw new Error('Custom export conditions specified but they are not an array of strings');
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
142
|
this.moduleMocker = new (_jestMock().ModuleMocker)(global);
|
|
@@ -182,6 +187,10 @@ class JSDOMEnvironment {
|
|
|
182
187
|
return null;
|
|
183
188
|
}
|
|
184
189
|
}
|
|
185
|
-
exports
|
|
186
|
-
const TestEnvironment = JSDOMEnvironment;
|
|
187
|
-
|
|
190
|
+
exports["default"] = JSDOMEnvironment;
|
|
191
|
+
const TestEnvironment = exports.TestEnvironment = JSDOMEnvironment;
|
|
192
|
+
})();
|
|
193
|
+
|
|
194
|
+
module.exports = __webpack_exports__;
|
|
195
|
+
/******/ })()
|
|
196
|
+
;
|
package/build/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jest-environment-jsdom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "30.0.0-alpha.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/jestjs/jest.git",
|
|
@@ -12,22 +12,24 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./build/index.d.ts",
|
|
15
|
+
"require": "./build/index.js",
|
|
16
|
+
"import": "./build/index.mjs",
|
|
15
17
|
"default": "./build/index.js"
|
|
16
18
|
},
|
|
17
19
|
"./package.json": "./package.json"
|
|
18
20
|
},
|
|
19
21
|
"dependencies": {
|
|
20
|
-
"@jest/environment": "
|
|
21
|
-
"@jest/fake-timers": "
|
|
22
|
-
"@jest/types": "
|
|
23
|
-
"@types/jsdom": "^
|
|
22
|
+
"@jest/environment": "30.0.0-alpha.2",
|
|
23
|
+
"@jest/fake-timers": "30.0.0-alpha.2",
|
|
24
|
+
"@jest/types": "30.0.0-alpha.2",
|
|
25
|
+
"@types/jsdom": "^21.1.1",
|
|
24
26
|
"@types/node": "*",
|
|
25
|
-
"jest-mock": "
|
|
26
|
-
"jest-util": "
|
|
27
|
-
"jsdom": "^
|
|
27
|
+
"jest-mock": "30.0.0-alpha.2",
|
|
28
|
+
"jest-util": "30.0.0-alpha.2",
|
|
29
|
+
"jsdom": "^22.0.0"
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
30
|
-
"@jest/test-utils": "
|
|
32
|
+
"@jest/test-utils": "30.0.0-alpha.2"
|
|
31
33
|
},
|
|
32
34
|
"peerDependencies": {
|
|
33
35
|
"canvas": "^2.5.0"
|
|
@@ -38,10 +40,10 @@
|
|
|
38
40
|
}
|
|
39
41
|
},
|
|
40
42
|
"engines": {
|
|
41
|
-
"node": "^
|
|
43
|
+
"node": "^16.10.0 || ^18.12.0 || >=20.0.0"
|
|
42
44
|
},
|
|
43
45
|
"publishConfig": {
|
|
44
46
|
"access": "public"
|
|
45
47
|
},
|
|
46
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "c04d13d7abd22e47b0997f6027886aed225c9ce4"
|
|
47
49
|
}
|