jest-environment-node
Advanced tools
Comparing version 27.5.1 to 28.0.0-alpha.0
@@ -8,23 +8,33 @@ /** | ||
/// <reference types="node" /> | ||
import { Context } from 'vm'; | ||
import type { JestEnvironment } from '@jest/environment'; | ||
import { LegacyFakeTimers, ModernFakeTimers } from '@jest/fake-timers'; | ||
import type { Config, Global } from '@jest/types'; | ||
import { ModuleMocker } from 'jest-mock'; | ||
import type {Config} from '@jest/types'; | ||
import {Context} from 'vm'; | ||
import type {Global} from '@jest/types'; | ||
import type {JestEnvironment} from '@jest/environment'; | ||
import {LegacyFakeTimers} from '@jest/fake-timers'; | ||
import {ModernFakeTimers} from '@jest/fake-timers'; | ||
import {ModuleMocker} from 'jest-mock'; | ||
declare class NodeEnvironment implements JestEnvironment<Timer> { | ||
context: Context | null; | ||
fakeTimers: LegacyFakeTimers<Timer> | null; | ||
fakeTimersModern: ModernFakeTimers | null; | ||
global: Global.Global; | ||
moduleMocker: ModuleMocker | null; | ||
constructor(config: Config.ProjectConfig); | ||
setup(): Promise<void>; | ||
teardown(): Promise<void>; | ||
exportConditions(): Array<string>; | ||
getVmContext(): Context | null; | ||
} | ||
export default NodeEnvironment; | ||
export declare const TestEnvironment: typeof NodeEnvironment; | ||
declare type Timer = { | ||
id: number; | ||
ref: () => Timer; | ||
unref: () => Timer; | ||
id: number; | ||
ref: () => Timer; | ||
unref: () => Timer; | ||
}; | ||
declare class NodeEnvironment implements JestEnvironment<Timer> { | ||
context: Context | null; | ||
fakeTimers: LegacyFakeTimers<Timer> | null; | ||
fakeTimersModern: ModernFakeTimers | null; | ||
global: Global.Global; | ||
moduleMocker: ModuleMocker | null; | ||
constructor(config: Config.ProjectConfig); | ||
setup(): Promise<void>; | ||
teardown(): Promise<void>; | ||
getVmContext(): Context | null; | ||
} | ||
export = NodeEnvironment; | ||
export {}; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.default = exports.TestEnvironment = void 0; | ||
function _vm() { | ||
@@ -43,28 +48,16 @@ const data = require('vm'); | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
class NodeEnvironment { | ||
context; | ||
fakeTimers; | ||
fakeTimersModern; | ||
global; | ||
moduleMocker; | ||
class NodeEnvironment { | ||
constructor(config) { | ||
_defineProperty(this, 'context', void 0); | ||
_defineProperty(this, 'fakeTimers', void 0); | ||
_defineProperty(this, 'fakeTimersModern', void 0); | ||
_defineProperty(this, 'global', void 0); | ||
_defineProperty(this, 'moduleMocker', void 0); | ||
this.context = (0, _vm().createContext)(); | ||
@@ -89,18 +82,9 @@ const global = (this.global = (0, _vm().runInContext)( | ||
if (typeof URL !== 'undefined' && typeof URLSearchParams !== 'undefined') { | ||
global.URL = URL; | ||
global.URLSearchParams = URLSearchParams; | ||
} // TextDecoder and TextDecoder are global in Node >= 11 | ||
global.URL = URL; | ||
global.URLSearchParams = URLSearchParams; // TextDecoder and TextDecoder are global in Node >= 11 | ||
if ( | ||
typeof TextEncoder !== 'undefined' && | ||
typeof TextDecoder !== 'undefined' | ||
) { | ||
global.TextEncoder = TextEncoder; | ||
global.TextDecoder = TextDecoder; | ||
} // queueMicrotask is global in Node >= 11 | ||
global.TextEncoder = TextEncoder; | ||
global.TextDecoder = TextDecoder; // queueMicrotask is global in Node >= 11 | ||
if (typeof queueMicrotask !== 'undefined') { | ||
global.queueMicrotask = queueMicrotask; | ||
} // AbortController is global in Node >= 15 | ||
global.queueMicrotask = queueMicrotask; // AbortController is global in Node >= 15 | ||
@@ -181,2 +165,6 @@ if (typeof AbortController !== 'undefined') { | ||
exportConditions() { | ||
return ['node', 'node-addons']; | ||
} | ||
getVmContext() { | ||
@@ -187,2 +175,4 @@ return this.context; | ||
module.exports = NodeEnvironment; | ||
exports.default = NodeEnvironment; | ||
const TestEnvironment = NodeEnvironment; | ||
exports.TestEnvironment = TestEnvironment; |
{ | ||
"name": "jest-environment-node", | ||
"version": "27.5.1", | ||
"version": "28.0.0-alpha.0", | ||
"repository": { | ||
@@ -20,14 +20,14 @@ "type": "git", | ||
"dependencies": { | ||
"@jest/environment": "^27.5.1", | ||
"@jest/fake-timers": "^27.5.1", | ||
"@jest/types": "^27.5.1", | ||
"@jest/environment": "^28.0.0-alpha.0", | ||
"@jest/fake-timers": "^28.0.0-alpha.0", | ||
"@jest/types": "^28.0.0-alpha.0", | ||
"@types/node": "*", | ||
"jest-mock": "^27.5.1", | ||
"jest-util": "^27.5.1" | ||
"jest-mock": "^28.0.0-alpha.0", | ||
"jest-util": "^28.0.0-alpha.0" | ||
}, | ||
"devDependencies": { | ||
"@jest/test-utils": "^27.5.1" | ||
"@jest/test-utils": "^28.0.0-alpha.0" | ||
}, | ||
"engines": { | ||
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" | ||
"node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0" | ||
}, | ||
@@ -37,3 +37,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "67c1aa20c5fec31366d733e901fee2b981cb1850" | ||
"gitHead": "89275b08977065d98e42ad71fcf223f4ad169f09" | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7314
170
2
+ Added@jest/environment@28.1.3(transitive)
+ Added@jest/fake-timers@28.1.3(transitive)
+ Added@jest/schemas@28.1.3(transitive)
+ Added@jest/types@28.1.3(transitive)
+ Added@sinclair/typebox@0.24.51(transitive)
+ Added@sinonjs/fake-timers@9.1.2(transitive)
+ Added@types/yargs@17.0.33(transitive)
+ Addedjest-message-util@28.1.3(transitive)
+ Addedjest-mock@28.1.3(transitive)
+ Addedjest-util@28.1.3(transitive)
+ Addedpretty-format@28.1.3(transitive)
+ Addedreact-is@18.3.1(transitive)
- Removed@jest/environment@27.5.1(transitive)
- Removed@jest/fake-timers@27.5.1(transitive)
- Removed@jest/types@27.5.1(transitive)
- Removed@sinonjs/fake-timers@8.1.0(transitive)
- Removed@types/yargs@16.0.9(transitive)
- Removedjest-message-util@27.5.1(transitive)
- Removedjest-mock@27.5.1(transitive)
- Removedjest-util@27.5.1(transitive)
- Removedpretty-format@27.5.1(transitive)
- Removedreact-is@17.0.2(transitive)
Updated@jest/types@^28.0.0-alpha.0
Updatedjest-mock@^28.0.0-alpha.0
Updatedjest-util@^28.0.0-alpha.0