@happy-dom/jest-environment 2.48.0 → 2.49.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/lib/index.js CHANGED
@@ -81,8 +81,8 @@ var HappyDOMEnvironment = /** @class */ (function () {
81
81
  this.global = this.window;
82
82
  this.moduleMocker = new jest_mock_1.ModuleMocker(this.window);
83
83
  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);
84
+ // Functions and Objects are not instances the "Function" and "Object" classes in the VM context for some reason
85
+ vm_1.default.runInContext('window.Function = (() => {}).constructor;window.Object = ({}).constructor;', this.global);
86
86
  // 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
87
  this.global.Error.stackTraceLimit = 100;
88
88
  // 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,+HAA+H;QAC/H,YAAE,CAAC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IAAI,CAAC;gBACzB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;gBACvB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;;;;KAC7B;IAED;;;;;OAKG;IACI,uCAAS,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,AA/FD,IA+FC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happy-dom/jest-environment",
3
- "version": "2.48.0",
3
+ "version": "2.49.2",
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",
@@ -53,7 +53,7 @@
53
53
  "@jest/environment": "^27.0.3",
54
54
  "@jest/fake-timers": "^27.0.3",
55
55
  "@jest/types": "^27.0.2",
56
- "happy-dom": "^2.48.0",
56
+ "happy-dom": "^2.49.2",
57
57
  "jest-mock": "^27.0.3",
58
58
  "jest-util": "^27.0.2"
59
59
  },
@@ -91,5 +91,5 @@
91
91
  "vue": "^2.6.12",
92
92
  "zone.js": "^0.10.3"
93
93
  },
94
- "gitHead": "d2c5638d574c3ebac0b7a22a9be63e3776b8969a"
94
+ "gitHead": "d5d8c15e0a6fbb7073754c50bedc071d639347ca"
95
95
  }
package/src/index.ts CHANGED
@@ -28,8 +28,11 @@ 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);
31
+ // Functions and Objects are not instances the "Function" and "Object" classes in the VM context for some reason
32
+ VM.runInContext(
33
+ 'window.Function = (() => {}).constructor;window.Object = ({}).constructor;',
34
+ this.global
35
+ );
33
36
 
34
37
  // 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
38
  this.global.Error.stackTraceLimit = 100;
@@ -0,0 +1,9 @@
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
+ });