jest-environment-jsdom 25.0.0 → 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/build/index.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  import { Script } from 'vm';
9
9
  import { Config, Global } from '@jest/types';
10
10
  import { ModuleMocker } from 'jest-mock';
11
- import { JestFakeTimers as FakeTimers } from '@jest/fake-timers';
11
+ import { JestFakeTimers as LegacyFakeTimers, LolexFakeTimers } from '@jest/fake-timers';
12
12
  import { EnvironmentContext, JestEnvironment } from '@jest/environment';
13
13
  import { JSDOM } from 'jsdom';
14
14
  declare type Win = Window & Global.Global & {
@@ -18,7 +18,8 @@ declare type Win = Window & Global.Global & {
18
18
  };
19
19
  declare class JSDOMEnvironment implements JestEnvironment {
20
20
  dom: JSDOM | null;
21
- fakeTimers: FakeTimers<number> | null;
21
+ fakeTimers: LegacyFakeTimers<number> | null;
22
+ fakeTimersLolex: LolexFakeTimers | null;
22
23
  global: Win;
23
24
  errorEventListener: ((event: Event & {
24
25
  error: Error;
@@ -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,OAAa,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,cAAc,IAAI,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC/D,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,CAA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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
@@ -11,7 +11,7 @@ function _jestUtil() {
11
11
  }
12
12
 
13
13
  function _jestMock() {
14
- const data = _interopRequireDefault(require('jest-mock'));
14
+ const data = require('jest-mock');
15
15
 
16
16
  _jestMock = function() {
17
17
  return data;
@@ -40,10 +40,6 @@ function _jsdom() {
40
40
  return data;
41
41
  }
42
42
 
43
- function _interopRequireDefault(obj) {
44
- return obj && obj.__esModule ? obj : {default: obj};
45
- }
46
-
47
43
  function ownKeys(object, enumerableOnly) {
48
44
  var keys = Object.keys(object);
49
45
  if (Object.getOwnPropertySymbols) {
@@ -61,13 +57,13 @@ function _objectSpread(target) {
61
57
  for (var i = 1; i < arguments.length; i++) {
62
58
  var source = arguments[i] != null ? arguments[i] : {};
63
59
  if (i % 2) {
64
- ownKeys(source, true).forEach(function(key) {
60
+ ownKeys(Object(source), true).forEach(function(key) {
65
61
  _defineProperty(target, key, source[key]);
66
62
  });
67
63
  } else if (Object.getOwnPropertyDescriptors) {
68
64
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
69
65
  } else {
70
- ownKeys(source).forEach(function(key) {
66
+ ownKeys(Object(source)).forEach(function(key) {
71
67
  Object.defineProperty(
72
68
  target,
73
69
  key,
@@ -99,20 +95,22 @@ class JSDOMEnvironment {
99
95
 
100
96
  _defineProperty(this, 'fakeTimers', void 0);
101
97
 
98
+ _defineProperty(this, 'fakeTimersLolex', void 0);
99
+
102
100
  _defineProperty(this, 'global', void 0);
103
101
 
104
102
  _defineProperty(this, 'errorEventListener', void 0);
105
103
 
106
104
  _defineProperty(this, 'moduleMocker', void 0);
107
105
 
108
- this.dom = new (_jsdom()).JSDOM(
106
+ this.dom = new (_jsdom().JSDOM)(
109
107
  '<!DOCTYPE html>',
110
108
  _objectSpread(
111
109
  {
112
110
  pretendToBeVisual: true,
113
111
  runScripts: 'dangerously',
114
112
  url: config.testURL,
115
- virtualConsole: new (_jsdom()).VirtualConsole().sendTo(
113
+ virtualConsole: new (_jsdom().VirtualConsole)().sendTo(
116
114
  options.console || console
117
115
  )
118
116
  },
@@ -158,28 +156,34 @@ class JSDOMEnvironment {
158
156
  return originalRemoveListener.apply(this, args);
159
157
  };
160
158
 
161
- this.moduleMocker = new (_jestMock()).default.ModuleMocker(global);
159
+ this.moduleMocker = new (_jestMock().ModuleMocker)(global);
162
160
  const timerConfig = {
163
161
  idToRef: id => id,
164
162
  refToId: ref => ref
165
163
  };
166
- this.fakeTimers = new (_fakeTimers()).JestFakeTimers({
164
+ this.fakeTimers = new (_fakeTimers().JestFakeTimers)({
167
165
  config,
168
- global: global,
166
+ global,
169
167
  moduleMocker: this.moduleMocker,
170
168
  timerConfig
171
169
  });
170
+ this.fakeTimersLolex = new (_fakeTimers().LolexFakeTimers)({
171
+ config,
172
+ global
173
+ });
172
174
  }
173
175
 
174
- setup() {
175
- return Promise.resolve();
176
- }
176
+ async setup() {}
177
177
 
178
- teardown() {
178
+ async teardown() {
179
179
  if (this.fakeTimers) {
180
180
  this.fakeTimers.dispose();
181
181
  }
182
182
 
183
+ if (this.fakeTimersLolex) {
184
+ this.fakeTimersLolex.dispose();
185
+ }
186
+
183
187
  if (this.global) {
184
188
  if (this.errorEventListener) {
185
189
  this.global.removeEventListener('error', this.errorEventListener);
@@ -196,7 +200,7 @@ class JSDOMEnvironment {
196
200
  this.global = null;
197
201
  this.dom = null;
198
202
  this.fakeTimers = null;
199
- return Promise.resolve();
203
+ this.fakeTimersLolex = null;
200
204
  }
201
205
 
202
206
  runScript(script) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-environment-jsdom",
3
- "version": "25.0.0",
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": "^25.0.0",
14
- "@jest/fake-timers": "^25.0.0",
15
- "@jest/types": "^25.0.0",
16
- "jest-mock": "^25.0.0",
17
- "jest-util": "^25.0.0",
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
18
  "jsdom": "^15.1.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/jsdom": "^12.2.4"
22
22
  },
23
23
  "engines": {
24
- "node": ">= 8"
24
+ "node": ">= 8.3"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
- "gitHead": "ff9269be05fd8316e95232198fce3463bf2f270e"
29
+ "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638"
30
30
  }