Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@happy-dom/jest-environment

Package Overview
Dependencies
Maintainers
1
Versions
531
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@happy-dom/jest-environment - npm Package Compare versions

Comparing version 13.7.3 to 13.7.4

38

lib/index.js

@@ -46,16 +46,4 @@ "use strict";

this.fakeTimersModern = null;
this.window = new happy_dom_1.Window({
console: globalThis.console,
settings: { disableErrorCapturing: true }
});
this.global = this.window;
this.moduleMocker = new jest_mock_1.ModuleMocker(this.window);
// Node's error-message stack size is limited to 10, but it's pretty useful to see more than that when a test fails.
this.global.Error.stackTraceLimit = 100;
// TODO: Remove this ASAP as it currently causes tests to run really slow.
this.global.Buffer = Buffer;
// Needed as Jest is using it
this.window['global'] = this.global;
let projectConfig;
let globals;
let projectConfig;
if (isJestConfigVersion29(config)) {

@@ -74,2 +62,20 @@ // Jest 29

}
// Initialize Window and Global
this.window = new happy_dom_1.Window({
url: 'http://localhost/',
...projectConfig.testEnvironmentOptions,
console: options.console,
settings: {
...projectConfig.testEnvironmentOptions?.settings,
errorCapture: happy_dom_1.BrowserErrorCaptureEnum.disabled
}
});
this.global = this.window;
this.moduleMocker = new jest_mock_1.ModuleMocker(this.window);
// Node's error-message stack size is limited to 10, but it's pretty useful to see more than that when a test fails.
this.global.Error.stackTraceLimit = 100;
// TODO: Remove this ASAP as it currently causes tests to run really slow.
this.global.Buffer = Buffer;
// Needed as Jest is using it
this.window['global'] = this.global;
JestUtil.installCommonGlobals(this.window, globals);

@@ -82,8 +88,2 @@ // For some reason Jest removes the global setImmediate, so we need to add it back.

}
if (projectConfig.testEnvironmentOptions['url']) {
this.window.happyDOM?.setURL(String(projectConfig.testEnvironmentOptions['url']));
}
else {
this.window.happyDOM?.setURL('http://localhost/');
}
this.fakeTimers = new fake_timers_1.LegacyFakeTimers({

@@ -90,0 +90,0 @@ config: projectConfig,

{
"name": "@happy-dom/jest-environment",
"version": "13.7.3",
"version": "13.7.4",
"license": "MIT",

@@ -53,3 +53,3 @@ "homepage": "https://github.com/capricorn86/happy-dom/tree/master/packages/jest-environment",

"@jest/types": "^29.4.0",
"happy-dom": "^13.7.3",
"happy-dom": "^13.7.4",
"jest-mock": "^29.4.0",

@@ -56,0 +56,0 @@ "jest-util": "^29.4.0"

@@ -77,5 +77,15 @@ ![Happy DOM Logo](https://github.com/capricorn86/happy-dom/raw/master/docs/happy-dom-logo.jpg)

{
"jest": {
"testEnvironment": "@happy-dom/jest-environment"
}
"jest": {
"testEnvironment": "@happy-dom/jest-environment",
"testEnvironmentOptions": {
"url": "http://localhost",
"width": 1920,
"height": 1080,
"settings": {
"navigator": {
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
}
}
}
}
}

@@ -93,3 +103,13 @@ ```

{
"testEnvironment": "@happy-dom/jest-environment"
"testEnvironment": "@happy-dom/jest-environment",
"testEnvironmentOptions": {
"url": "http://localhost",
"width": 1920,
"height": 1080,
"settings": {
"navigator": {
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
}
}
}
}

@@ -96,0 +116,0 @@ ```

@@ -8,3 +8,3 @@ /* eslint-disable filenames/match-exported */

import { JestEnvironment, EnvironmentContext } from '@jest/environment';
import { Window, IWindow } from 'happy-dom';
import { Window, IWindow, BrowserErrorCaptureEnum, IOptionalBrowserSettings } from 'happy-dom';
import { Script } from 'vm';

@@ -19,8 +19,5 @@ import { Global, Config } from '@jest/types';

public fakeTimersModern: ModernFakeTimers = null;
public window: IWindow = new Window({
console: globalThis.console,
settings: { disableErrorCapturing: true }
});
public global: Global.Global = <Global.Global>(<unknown>this.window);
public moduleMocker: ModuleMocker = new ModuleMocker(<typeof globalThis>(<unknown>this.window));
public window: IWindow;
public global: Global.Global;
public moduleMocker: ModuleMocker;

@@ -41,13 +38,4 @@ /**

) {
// Node's error-message stack size is limited to 10, but it's pretty useful to see more than that when a test fails.
this.global.Error.stackTraceLimit = 100;
// TODO: Remove this ASAP as it currently causes tests to run really slow.
this.global.Buffer = Buffer;
// Needed as Jest is using it
this.window['global'] = this.global;
let projectConfig: Config.ProjectConfig;
let globals: Config.ConfigGlobals;
let projectConfig: Config.ProjectConfig;
if (isJestConfigVersion29(config)) {

@@ -65,2 +53,24 @@ // Jest 29

// Initialize Window and Global
this.window = new Window({
url: 'http://localhost/',
...projectConfig.testEnvironmentOptions,
console: options.console,
settings: {
...(<IOptionalBrowserSettings>projectConfig.testEnvironmentOptions?.settings),
errorCapture: BrowserErrorCaptureEnum.disabled
}
});
this.global = <Global.Global>(<unknown>this.window);
this.moduleMocker = new ModuleMocker(<typeof globalThis>(<unknown>this.window));
// Node's error-message stack size is limited to 10, but it's pretty useful to see more than that when a test fails.
this.global.Error.stackTraceLimit = 100;
// TODO: Remove this ASAP as it currently causes tests to run really slow.
this.global.Buffer = Buffer;
// Needed as Jest is using it
this.window['global'] = this.global;
JestUtil.installCommonGlobals(<typeof globalThis>(<unknown>this.window), globals);

@@ -76,8 +86,2 @@

if (projectConfig.testEnvironmentOptions['url']) {
this.window.happyDOM?.setURL(String(projectConfig.testEnvironmentOptions['url']));
} else {
this.window.happyDOM?.setURL('http://localhost/');
}
this.fakeTimers = new LegacyFakeTimers({

@@ -84,0 +88,0 @@ config: projectConfig,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc