Updating NPM dependencies

This commit is contained in:
Drew Heavner
2020-11-11 13:30:52 +00:00
committed by GitHub
parent 7a6fb66c63
commit bd487ef324
9068 changed files with 1400893 additions and 587661 deletions

View File

@@ -5,11 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/
/// <reference types="node" />
import { Script, Context } from 'vm';
import { Global, Config } from '@jest/types';
import { Context, Script } 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 { JestFakeTimers as FakeTimers } from '@jest/fake-timers';
import { JestEnvironment } from '@jest/environment';
declare type Timer = {
id: number;
ref: () => Timer;
@@ -17,13 +17,14 @@ declare type Timer = {
};
declare class NodeEnvironment implements JestEnvironment {
context: Context | null;
fakeTimers: FakeTimers<Timer> | null;
fakeTimers: LegacyFakeTimers<Timer> | null;
fakeTimersModern: ModernFakeTimers | null;
global: Global.Global;
moduleMocker: ModuleMocker | null;
constructor(config: Config.ProjectConfig);
setup(): Promise<void>;
teardown(): Promise<void>;
runScript(script: Script): any;
runScript<T = unknown>(script: Script): T | null;
getVmContext(): Context | null;
}
export = NodeEnvironment;
//# sourceMappingURL=index.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAW,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,IAAI,CAAC;AACvC,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAC,cAAc,IAAI,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,aAAK,KAAK,GAAG;IACX,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,KAAK,CAAC;IACjB,KAAK,EAAE,MAAM,KAAK,CAAC;CACpB,CAAC;AAEF,cAAM,eAAgB,YAAW,eAAe;IAC9C,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;IACtB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;gBAEtB,MAAM,EAAE,MAAM,CAAC,aAAa;IAwDxC,KAAK;IAIL,QAAQ;IAWR,SAAS,CAAC,MAAM,EAAE,MAAM;CAMzB;AAED,SAAS,eAAe,CAAC"}

View File

@@ -1,29 +1,9 @@
'use strict';
function _vm() {
const data = _interopRequireDefault(require('vm'));
const data = require('vm');
_vm = function _vm() {
return data;
};
return data;
}
function _jestMock() {
const data = require('jest-mock');
_jestMock = function _jestMock() {
return data;
};
return data;
}
function _jestUtil() {
const data = require('jest-util');
_jestUtil = function _jestUtil() {
_vm = function () {
return data;
};
@@ -33,15 +13,31 @@ function _jestUtil() {
function _fakeTimers() {
const data = require('@jest/fake-timers');
_fakeTimers = function _fakeTimers() {
_fakeTimers = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
function _jestMock() {
const data = require('jest-mock');
_jestMock = function () {
return data;
};
return data;
}
function _jestUtil() {
const data = require('jest-util');
_jestUtil = function () {
return data;
};
return data;
}
function _defineProperty(obj, key, value) {
@@ -64,26 +60,29 @@ class NodeEnvironment {
_defineProperty(this, 'fakeTimers', void 0);
_defineProperty(this, 'fakeTimersModern', void 0);
_defineProperty(this, 'global', void 0);
_defineProperty(this, 'moduleMocker', void 0);
this.context = _vm().default.createContext();
const global = (this.global = _vm().default.runInContext(
this.context = (0, _vm().createContext)();
const global = (this.global = (0, _vm().runInContext)(
'this',
Object.assign(this.context, config.testEnvironmentOptions)
));
global.global = global;
global.clearInterval = clearInterval;
global.clearTimeout = clearTimeout;
global.setInterval = setInterval;
global.setTimeout = setTimeout;
global.ArrayBuffer = ArrayBuffer; // URL and URLSearchParams are global in Node >= 10
global.ArrayBuffer = ArrayBuffer; // TextEncoder (global or via 'util') references a Uint8Array constructor
// different than the global one used by users in tests. This makes sure the
// same constructor is referenced by both.
global.Uint8Array = Uint8Array; // URL and URLSearchParams are global in Node >= 10
if (typeof URL !== 'undefined' && typeof URLSearchParams !== 'undefined') {
/* global URL, URLSearchParams */
global.URL = URL;
global.URLSearchParams = URLSearchParams;
} // TextDecoder and TextDecoder are global in Node >= 11
@@ -92,13 +91,16 @@ class NodeEnvironment {
typeof TextEncoder !== 'undefined' &&
typeof TextDecoder !== 'undefined'
) {
/* global TextEncoder, TextDecoder */
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
} // queueMicrotask is global in Node >= 11
if (typeof queueMicrotask !== 'undefined') {
global.queueMicrotask = queueMicrotask;
}
(0, _jestUtil().installCommonGlobals)(global, config.globals);
this.moduleMocker = new (_jestMock()).ModuleMocker(global);
this.moduleMocker = new (_jestMock().ModuleMocker)(global);
const timerIdToRef = id => ({
id,
@@ -118,26 +120,32 @@ class NodeEnvironment {
idToRef: timerIdToRef,
refToId: timerRefToId
};
this.fakeTimers = new (_fakeTimers()).JestFakeTimers({
this.fakeTimers = new (_fakeTimers().LegacyFakeTimers)({
config,
global,
moduleMocker: this.moduleMocker,
timerConfig
});
this.fakeTimersModern = new (_fakeTimers().ModernFakeTimers)({
config,
global
});
}
setup() {
return Promise.resolve();
}
async setup() {}
teardown() {
async teardown() {
if (this.fakeTimers) {
this.fakeTimers.dispose();
}
if (this.fakeTimersModern) {
this.fakeTimersModern.dispose();
}
this.context = null;
this.fakeTimers = null;
return Promise.resolve();
this.fakeTimersModern = null;
} // TS infers the return type to be `any`, since that's what `runInContext`
// returns.
@@ -148,6 +156,10 @@ class NodeEnvironment {
return null;
}
getVmContext() {
return this.context;
}
}
module.exports = NodeEnvironment;