jest-environment-jsdom 29.7.0 → 30.0.0-alpha.1

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
 
9
9
  import type {Context} from 'vm';
10
10
  import type {EnvironmentContext} from '@jest/environment';
11
- import type {Global} from '@jest/types';
11
+ import type {Global as Global_2} from '@jest/types';
12
12
  import type {JestEnvironment} from '@jest/environment';
13
13
  import type {JestEnvironmentConfig} from '@jest/environment';
14
14
  import {JSDOM} from 'jsdom';
@@ -24,7 +24,7 @@ declare class JSDOMEnvironment implements JestEnvironment<number> {
24
24
  private errorEventListener;
25
25
  moduleMocker: ModuleMocker | null;
26
26
  customExportConditions: string[];
27
- private _configuredExportConditions?;
27
+ private readonly _configuredExportConditions?;
28
28
  constructor(config: JestEnvironmentConfig, context: EnvironmentContext);
29
29
  setup(): Promise<void>;
30
30
  teardown(): Promise<void>;
@@ -36,7 +36,7 @@ export default JSDOMEnvironment;
36
36
  export declare const TestEnvironment: typeof JSDOMEnvironment;
37
37
 
38
38
  declare type Win = Window &
39
- Global.Global & {
39
+ Global_2.Global & {
40
40
  Error: {
41
41
  stackTraceLimit: number;
42
42
  };
package/build/index.js CHANGED
@@ -1,32 +1,46 @@
1
- 'use strict';
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, '__esModule', {
17
+ Object.defineProperty(exports, "__esModule", ({
4
18
  value: true
5
- });
6
- exports.default = exports.TestEnvironment = void 0;
19
+ }));
20
+ exports["default"] = exports.TestEnvironment = void 0;
7
21
  function _jsdom() {
8
- const data = require('jsdom');
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('@jest/fake-timers');
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('jest-mock');
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('jest-util');
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 {projectConfig} = config;
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
- typeof projectConfig.testEnvironmentOptions.html === 'string'
67
- ? projectConfig.testEnvironmentOptions.html
68
- : '<!DOCTYPE html>',
69
- {
70
- pretendToBeVisual: true,
71
- resources:
72
- typeof projectConfig.testEnvironmentOptions.userAgent === 'string'
73
- ? new (_jsdom().ResourceLoader)({
74
- userAgent: projectConfig.testEnvironmentOptions.userAgent
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
- // @ts-expect-error - for "universal" code (code should use `globalThis`)
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 {customExportConditions} = projectConfig.testEnvironmentOptions;
126
- if (
127
- Array.isArray(customExportConditions) &&
128
- customExportConditions.every(isString)
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.default = JSDOMEnvironment;
186
- const TestEnvironment = JSDOMEnvironment;
187
- exports.TestEnvironment = TestEnvironment;
190
+ exports["default"] = JSDOMEnvironment;
191
+ const TestEnvironment = exports.TestEnvironment = JSDOMEnvironment;
192
+ })();
193
+
194
+ module.exports = __webpack_exports__;
195
+ /******/ })()
196
+ ;
@@ -0,0 +1,4 @@
1
+ import cjsModule from './index.js';
2
+
3
+ export const TestEnvironment = cjsModule.TestEnvironment;
4
+ export default cjsModule.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-environment-jsdom",
3
- "version": "29.7.0",
3
+ "version": "30.0.0-alpha.1",
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": "^29.7.0",
21
- "@jest/fake-timers": "^29.7.0",
22
- "@jest/types": "^29.6.3",
23
- "@types/jsdom": "^20.0.0",
22
+ "@jest/environment": "30.0.0-alpha.1",
23
+ "@jest/fake-timers": "30.0.0-alpha.1",
24
+ "@jest/types": "30.0.0-alpha.1",
25
+ "@types/jsdom": "^21.1.1",
24
26
  "@types/node": "*",
25
- "jest-mock": "^29.7.0",
26
- "jest-util": "^29.7.0",
27
- "jsdom": "^20.0.0"
27
+ "jest-mock": "30.0.0-alpha.1",
28
+ "jest-util": "30.0.0-alpha.1",
29
+ "jsdom": "^22.0.0"
28
30
  },
29
31
  "devDependencies": {
30
- "@jest/test-utils": "^29.7.0"
32
+ "@jest/test-utils": "30.0.0-alpha.1"
31
33
  },
32
34
  "peerDependencies": {
33
35
  "canvas": "^2.5.0"
@@ -38,10 +40,10 @@
38
40
  }
39
41
  },
40
42
  "engines": {
41
- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
43
+ "node": "^16.10.0 || ^18.12.0 || >=20.0.0"
42
44
  },
43
45
  "publishConfig": {
44
46
  "access": "public"
45
47
  },
46
- "gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630"
48
+ "gitHead": "d005cb2505c041583e0c5636d006e08666a54b63"
47
49
  }