jest-environment-node
Advanced tools
Comparing version 29.7.0 to 30.0.0-alpha.1
@@ -11,3 +11,3 @@ /** | ||
import type {EnvironmentContext} from '@jest/environment'; | ||
import type {Global} from '@jest/types'; | ||
import type {Global as Global_2} from '@jest/types'; | ||
import type {JestEnvironment} from '@jest/environment'; | ||
@@ -23,6 +23,6 @@ import type {JestEnvironmentConfig} from '@jest/environment'; | ||
fakeTimersModern: ModernFakeTimers | null; | ||
global: Global.Global; | ||
global: Global_2.Global; | ||
moduleMocker: ModuleMocker | null; | ||
customExportConditions: string[]; | ||
private _configuredExportConditions?; | ||
private readonly _configuredExportConditions?; | ||
constructor(config: JestEnvironmentConfig, _context: EnvironmentContext); | ||
@@ -29,0 +29,0 @@ setup(): Promise<void>; |
@@ -1,9 +0,23 @@ | ||
'use strict'; | ||
/*! | ||
* /** | ||
* * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* * | ||
* * This source code is licensed under the MIT license found in the | ||
* * LICENSE file in the root directory of this source tree. | ||
* * / | ||
*/ | ||
/******/ (() => { // webpackBootstrap | ||
/******/ "use strict"; | ||
var __webpack_exports__ = {}; | ||
// This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports). | ||
(() => { | ||
var exports = __webpack_exports__; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", ({ | ||
value: true | ||
}); | ||
exports.default = exports.TestEnvironment = void 0; | ||
})); | ||
exports["default"] = exports.TestEnvironment = void 0; | ||
function _vm() { | ||
const data = require('vm'); | ||
const data = require("vm"); | ||
_vm = function () { | ||
@@ -15,3 +29,3 @@ return data; | ||
function _fakeTimers() { | ||
const data = require('@jest/fake-timers'); | ||
const data = require("@jest/fake-timers"); | ||
_fakeTimers = function () { | ||
@@ -23,3 +37,3 @@ return data; | ||
function _jestMock() { | ||
const data = require('jest-mock'); | ||
const data = require("jest-mock"); | ||
_jestMock = function () { | ||
@@ -31,3 +45,3 @@ return data; | ||
function _jestUtil() { | ||
const data = require('jest-util'); | ||
const data = require("jest-util"); | ||
_jestUtil = function () { | ||
@@ -46,29 +60,12 @@ return data; | ||
// some globals we do not want, either because deprecated or we set it ourselves | ||
const denyList = new Set([ | ||
'GLOBAL', | ||
'root', | ||
'global', | ||
'globalThis', | ||
'Buffer', | ||
'ArrayBuffer', | ||
'Uint8Array', | ||
// if env is loaded within a jest test | ||
'jest-symbol-do-not-touch' | ||
]); | ||
const nodeGlobals = new Map( | ||
Object.getOwnPropertyNames(globalThis) | ||
.filter(global => !denyList.has(global)) | ||
.map(nodeGlobalsKey => { | ||
const descriptor = Object.getOwnPropertyDescriptor( | ||
globalThis, | ||
nodeGlobalsKey | ||
); | ||
if (!descriptor) { | ||
throw new Error( | ||
`No property descriptor for ${nodeGlobalsKey}, this is a bug in Jest.` | ||
); | ||
} | ||
return [nodeGlobalsKey, descriptor]; | ||
}) | ||
); | ||
const denyList = new Set(['GLOBAL', 'root', 'global', 'globalThis', 'Buffer', 'ArrayBuffer', 'Uint8Array', | ||
// if env is loaded within a jest test | ||
'jest-symbol-do-not-touch']); | ||
const nodeGlobals = new Map(Object.getOwnPropertyNames(globalThis).filter(global => !denyList.has(global)).map(nodeGlobalsKey => { | ||
const descriptor = Object.getOwnPropertyDescriptor(globalThis, nodeGlobalsKey); | ||
if (!descriptor) { | ||
throw new Error(`No property descriptor for ${nodeGlobalsKey}, this is a bug in Jest.`); | ||
} | ||
return [nodeGlobalsKey, descriptor]; | ||
})); | ||
function isString(value) { | ||
@@ -88,8 +85,7 @@ return typeof value === 'string'; | ||
constructor(config, _context) { | ||
const {projectConfig} = config; | ||
const { | ||
projectConfig | ||
} = config; | ||
this.context = (0, _vm().createContext)(); | ||
const global = (0, _vm().runInContext)( | ||
'this', | ||
Object.assign(this.context, projectConfig.testEnvironmentOptions) | ||
); | ||
const global = (0, _vm().runInContext)('this', Object.assign(this.context, projectConfig.testEnvironmentOptions)); | ||
this.global = global; | ||
@@ -142,4 +138,2 @@ const contextGlobals = new Set(Object.getOwnPropertyNames(global)); | ||
} | ||
// @ts-expect-error - Buffer and gc is "missing" | ||
global.global = global; | ||
@@ -158,12 +152,9 @@ global.Buffer = Buffer; | ||
if ('customExportConditions' in projectConfig.testEnvironmentOptions) { | ||
const {customExportConditions} = projectConfig.testEnvironmentOptions; | ||
if ( | ||
Array.isArray(customExportConditions) && | ||
customExportConditions.every(isString) | ||
) { | ||
const { | ||
customExportConditions | ||
} = projectConfig.testEnvironmentOptions; | ||
if (Array.isArray(customExportConditions) && customExportConditions.every(isString)) { | ||
this._configuredExportConditions = customExportConditions; | ||
} else { | ||
throw new Error( | ||
'Custom export conditions specified but they are not an array of strings' | ||
); | ||
throw new Error('Custom export conditions specified but they are not an array of strings'); | ||
} | ||
@@ -217,4 +208,8 @@ } | ||
} | ||
exports.default = NodeEnvironment; | ||
const TestEnvironment = NodeEnvironment; | ||
exports.TestEnvironment = TestEnvironment; | ||
exports["default"] = NodeEnvironment; | ||
const TestEnvironment = exports.TestEnvironment = NodeEnvironment; | ||
})(); | ||
module.exports = __webpack_exports__; | ||
/******/ })() | ||
; |
{ | ||
"name": "jest-environment-node", | ||
"version": "29.7.0", | ||
"version": "30.0.0-alpha.1", | ||
"repository": { | ||
@@ -15,2 +15,4 @@ "type": "git", | ||
"types": "./build/index.d.ts", | ||
"require": "./build/index.js", | ||
"import": "./build/index.mjs", | ||
"default": "./build/index.js" | ||
@@ -21,14 +23,14 @@ }, | ||
"dependencies": { | ||
"@jest/environment": "^29.7.0", | ||
"@jest/fake-timers": "^29.7.0", | ||
"@jest/types": "^29.6.3", | ||
"@jest/environment": "30.0.0-alpha.1", | ||
"@jest/fake-timers": "30.0.0-alpha.1", | ||
"@jest/types": "30.0.0-alpha.1", | ||
"@types/node": "*", | ||
"jest-mock": "^29.7.0", | ||
"jest-util": "^29.7.0" | ||
"jest-mock": "30.0.0-alpha.1", | ||
"jest-util": "30.0.0-alpha.1" | ||
}, | ||
"devDependencies": { | ||
"@jest/test-utils": "^29.7.0" | ||
"@jest/test-utils": "30.0.0-alpha.1" | ||
}, | ||
"engines": { | ||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0" | ||
"node": "^16.10.0 || ^18.12.0 || >=20.0.0" | ||
}, | ||
@@ -38,3 +40,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630" | ||
"gitHead": "d005cb2505c041583e0c5636d006e08666a54b63" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
9950
5
238
2
+ Added@jest/environment@30.0.0-alpha.1(transitive)
+ Added@jest/fake-timers@30.0.0-alpha.1(transitive)
+ Added@jest/schemas@30.0.0-alpha.1(transitive)
+ Added@jest/types@30.0.0-alpha.1(transitive)
+ Added@sinclair/typebox@0.31.28(transitive)
+ Added@sinonjs/fake-timers@11.3.1(transitive)
+ Addedci-info@4.0.0(transitive)
+ Addedjest-message-util@30.0.0-alpha.1(transitive)
+ Addedjest-mock@30.0.0-alpha.1(transitive)
+ Addedjest-util@30.0.0-alpha.1(transitive)
+ Addedpretty-format@30.0.0-alpha.1(transitive)
- Removed@jest/environment@29.7.0(transitive)
- Removed@jest/fake-timers@29.7.0(transitive)
- Removed@jest/schemas@29.6.3(transitive)
- Removed@jest/types@29.6.3(transitive)
- Removed@sinclair/typebox@0.27.8(transitive)
- Removed@sinonjs/fake-timers@10.3.0(transitive)
- Removedci-info@3.9.0(transitive)
- Removedjest-message-util@29.7.0(transitive)
- Removedjest-mock@29.7.0(transitive)
- Removedjest-util@29.7.0(transitive)
- Removedpretty-format@29.7.0(transitive)
Updated@jest/types@30.0.0-alpha.1
Updatedjest-mock@30.0.0-alpha.1
Updatedjest-util@30.0.0-alpha.1