jest-environment-jsdom 24.7.1 → 25.1.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/LICENSE +1 -3
- package/build/index.d.ts +8 -7
- package/build/index.d.ts.map +1 -1
- package/build/index.js +52 -39
- package/package.json +10 -10
- package/tsconfig.json +0 -14
- package/tsconfig.tsbuildinfo +0 -2872
package/LICENSE
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2014-present, Facebook, Inc.
|
|
3
|
+
Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
4
|
|
|
7
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/build/index.d.ts
CHANGED
|
@@ -6,20 +6,21 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="node" />
|
|
8
8
|
import { Script } from 'vm';
|
|
9
|
-
import {
|
|
9
|
+
import { Config, Global } from '@jest/types';
|
|
10
10
|
import { ModuleMocker } from 'jest-mock';
|
|
11
|
-
import { JestFakeTimers as
|
|
12
|
-
import {
|
|
11
|
+
import { JestFakeTimers as LegacyFakeTimers, LolexFakeTimers } from '@jest/fake-timers';
|
|
12
|
+
import { EnvironmentContext, JestEnvironment } from '@jest/environment';
|
|
13
13
|
import { JSDOM } from 'jsdom';
|
|
14
|
-
|
|
14
|
+
declare type Win = Window & Global.Global & {
|
|
15
15
|
Error: {
|
|
16
16
|
stackTraceLimit: number;
|
|
17
17
|
};
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
declare class JSDOMEnvironment implements JestEnvironment {
|
|
20
20
|
dom: JSDOM | null;
|
|
21
|
-
fakeTimers:
|
|
22
|
-
|
|
21
|
+
fakeTimers: LegacyFakeTimers<number> | null;
|
|
22
|
+
fakeTimersLolex: LolexFakeTimers | null;
|
|
23
|
+
global: Win;
|
|
23
24
|
errorEventListener: ((event: Event & {
|
|
24
25
|
error: Error;
|
|
25
26
|
}) => void) | null;
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,aAAa,CAAC;AAE3C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,cAAc,IAAI,gBAAgB,EAClC,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAC,KAAK,EAAiB,MAAM,OAAO,CAAC;AAI5C,aAAK,GAAG,GAAG,MAAM,GACf,MAAM,CAAC,MAAM,GAAG;IACd,KAAK,EAAE;QACL,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH,CAAC;AAEJ,cAAM,gBAAiB,YAAW,eAAe;IAC/C,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC;IAClB,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC5C,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,MAAM,EAAE,GAAG,CAAC;IACZ,kBAAkB,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG;QAAC,KAAK,EAAE,KAAK,CAAA;KAAC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACrE,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;gBAEtB,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,OAAO,GAAE,kBAAuB;IAkEpE,KAAK;IAEL,QAAQ;IAuBd,SAAS,CAAC,MAAM,EAAE,MAAM;CAMzB;AAED,SAAS,gBAAgB,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
function _jestUtil() {
|
|
4
4
|
const data = require('jest-util');
|
|
5
5
|
|
|
6
|
-
_jestUtil = function
|
|
6
|
+
_jestUtil = function() {
|
|
7
7
|
return data;
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -11,9 +11,9 @@ function _jestUtil() {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function _jestMock() {
|
|
14
|
-
const data =
|
|
14
|
+
const data = require('jest-mock');
|
|
15
15
|
|
|
16
|
-
_jestMock = function
|
|
16
|
+
_jestMock = function() {
|
|
17
17
|
return data;
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -23,7 +23,7 @@ function _jestMock() {
|
|
|
23
23
|
function _fakeTimers() {
|
|
24
24
|
const data = require('@jest/fake-timers');
|
|
25
25
|
|
|
26
|
-
_fakeTimers = function
|
|
26
|
+
_fakeTimers = function() {
|
|
27
27
|
return data;
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -33,31 +33,44 @@ function _fakeTimers() {
|
|
|
33
33
|
function _jsdom() {
|
|
34
34
|
const data = require('jsdom');
|
|
35
35
|
|
|
36
|
-
_jsdom = function
|
|
36
|
+
_jsdom = function() {
|
|
37
37
|
return data;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
return data;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function
|
|
44
|
-
|
|
43
|
+
function ownKeys(object, enumerableOnly) {
|
|
44
|
+
var keys = Object.keys(object);
|
|
45
|
+
if (Object.getOwnPropertySymbols) {
|
|
46
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
47
|
+
if (enumerableOnly)
|
|
48
|
+
symbols = symbols.filter(function(sym) {
|
|
49
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
50
|
+
});
|
|
51
|
+
keys.push.apply(keys, symbols);
|
|
52
|
+
}
|
|
53
|
+
return keys;
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
function _objectSpread(target) {
|
|
48
57
|
for (var i = 1; i < arguments.length; i++) {
|
|
49
58
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
if (i % 2) {
|
|
60
|
+
ownKeys(Object(source), true).forEach(function(key) {
|
|
61
|
+
_defineProperty(target, key, source[key]);
|
|
62
|
+
});
|
|
63
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
64
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
65
|
+
} else {
|
|
66
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
67
|
+
Object.defineProperty(
|
|
68
|
+
target,
|
|
69
|
+
key,
|
|
70
|
+
Object.getOwnPropertyDescriptor(source, key)
|
|
71
|
+
);
|
|
72
|
+
});
|
|
57
73
|
}
|
|
58
|
-
ownKeys.forEach(function(key) {
|
|
59
|
-
_defineProperty(target, key, source[key]);
|
|
60
|
-
});
|
|
61
74
|
}
|
|
62
75
|
return target;
|
|
63
76
|
}
|
|
@@ -76,32 +89,28 @@ function _defineProperty(obj, key, value) {
|
|
|
76
89
|
return obj;
|
|
77
90
|
}
|
|
78
91
|
|
|
79
|
-
function isWin(globals) {
|
|
80
|
-
return globals.document !== undefined;
|
|
81
|
-
} // A lot of the globals expected by other APIs are `NodeJS.Global` and not
|
|
82
|
-
// `Window`, so we need to cast here and there
|
|
83
|
-
|
|
84
92
|
class JSDOMEnvironment {
|
|
85
|
-
// @ts-ignore
|
|
86
93
|
constructor(config, options = {}) {
|
|
87
94
|
_defineProperty(this, 'dom', void 0);
|
|
88
95
|
|
|
89
96
|
_defineProperty(this, 'fakeTimers', void 0);
|
|
90
97
|
|
|
98
|
+
_defineProperty(this, 'fakeTimersLolex', void 0);
|
|
99
|
+
|
|
91
100
|
_defineProperty(this, 'global', void 0);
|
|
92
101
|
|
|
93
102
|
_defineProperty(this, 'errorEventListener', void 0);
|
|
94
103
|
|
|
95
104
|
_defineProperty(this, 'moduleMocker', void 0);
|
|
96
105
|
|
|
97
|
-
this.dom = new (_jsdom()
|
|
106
|
+
this.dom = new (_jsdom().JSDOM)(
|
|
98
107
|
'<!DOCTYPE html>',
|
|
99
108
|
_objectSpread(
|
|
100
109
|
{
|
|
101
110
|
pretendToBeVisual: true,
|
|
102
111
|
runScripts: 'dangerously',
|
|
103
112
|
url: config.testURL,
|
|
104
|
-
virtualConsole: new (_jsdom()
|
|
113
|
+
virtualConsole: new (_jsdom().VirtualConsole)().sendTo(
|
|
105
114
|
options.console || console
|
|
106
115
|
)
|
|
107
116
|
},
|
|
@@ -147,47 +156,51 @@ class JSDOMEnvironment {
|
|
|
147
156
|
return originalRemoveListener.apply(this, args);
|
|
148
157
|
};
|
|
149
158
|
|
|
150
|
-
this.moduleMocker = new (_jestMock()
|
|
159
|
+
this.moduleMocker = new (_jestMock().ModuleMocker)(global);
|
|
151
160
|
const timerConfig = {
|
|
152
161
|
idToRef: id => id,
|
|
153
162
|
refToId: ref => ref
|
|
154
163
|
};
|
|
155
|
-
this.fakeTimers = new (_fakeTimers()
|
|
164
|
+
this.fakeTimers = new (_fakeTimers().JestFakeTimers)({
|
|
156
165
|
config,
|
|
157
|
-
global
|
|
166
|
+
global,
|
|
158
167
|
moduleMocker: this.moduleMocker,
|
|
159
168
|
timerConfig
|
|
160
169
|
});
|
|
170
|
+
this.fakeTimersLolex = new (_fakeTimers().LolexFakeTimers)({
|
|
171
|
+
config,
|
|
172
|
+
global
|
|
173
|
+
});
|
|
161
174
|
}
|
|
162
175
|
|
|
163
|
-
setup() {
|
|
164
|
-
return Promise.resolve();
|
|
165
|
-
}
|
|
176
|
+
async setup() {}
|
|
166
177
|
|
|
167
|
-
teardown() {
|
|
178
|
+
async teardown() {
|
|
168
179
|
if (this.fakeTimers) {
|
|
169
180
|
this.fakeTimers.dispose();
|
|
170
181
|
}
|
|
171
182
|
|
|
183
|
+
if (this.fakeTimersLolex) {
|
|
184
|
+
this.fakeTimersLolex.dispose();
|
|
185
|
+
}
|
|
186
|
+
|
|
172
187
|
if (this.global) {
|
|
173
|
-
if (this.errorEventListener
|
|
188
|
+
if (this.errorEventListener) {
|
|
174
189
|
this.global.removeEventListener('error', this.errorEventListener);
|
|
175
190
|
} // Dispose "document" to prevent "load" event from triggering.
|
|
176
191
|
|
|
177
192
|
Object.defineProperty(this.global, 'document', {
|
|
178
193
|
value: null
|
|
179
194
|
});
|
|
180
|
-
|
|
181
|
-
if (isWin(this.global)) {
|
|
182
|
-
this.global.close();
|
|
183
|
-
}
|
|
195
|
+
this.global.close();
|
|
184
196
|
}
|
|
185
197
|
|
|
186
|
-
this.errorEventListener = null;
|
|
198
|
+
this.errorEventListener = null; // @ts-ignore
|
|
199
|
+
|
|
187
200
|
this.global = null;
|
|
188
201
|
this.dom = null;
|
|
189
202
|
this.fakeTimers = null;
|
|
190
|
-
|
|
203
|
+
this.fakeTimersLolex = null;
|
|
191
204
|
}
|
|
192
205
|
|
|
193
206
|
runScript(script) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jest-environment-jsdom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "25.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/facebook/jest.git",
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
"main": "build/index.js",
|
|
11
11
|
"types": "build/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@jest/environment": "^
|
|
14
|
-
"@jest/fake-timers": "^
|
|
15
|
-
"@jest/types": "^
|
|
16
|
-
"jest-mock": "^
|
|
17
|
-
"jest-util": "^
|
|
18
|
-
"jsdom": "^
|
|
13
|
+
"@jest/environment": "^25.1.0",
|
|
14
|
+
"@jest/fake-timers": "^25.1.0",
|
|
15
|
+
"@jest/types": "^25.1.0",
|
|
16
|
+
"jest-mock": "^25.1.0",
|
|
17
|
+
"jest-util": "^25.1.0",
|
|
18
|
+
"jsdom": "^15.1.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@types/jsdom": "^
|
|
21
|
+
"@types/jsdom": "^12.2.4"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
24
|
+
"node": ">= 8.3"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638"
|
|
30
30
|
}
|
package/tsconfig.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "build",
|
|
5
|
-
"rootDir": "src"
|
|
6
|
-
},
|
|
7
|
-
"references": [
|
|
8
|
-
{"path": "../jest-environment"},
|
|
9
|
-
{"path": "../jest-fake-timers"},
|
|
10
|
-
{"path": "../jest-mock"},
|
|
11
|
-
{"path": "../jest-types"},
|
|
12
|
-
{"path": "../jest-util"}
|
|
13
|
-
]
|
|
14
|
-
}
|