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,12 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/
/// <reference types="node" />
import { Script } from 'vm';
import { Global, Config } from '@jest/types';
import { ModuleMocker } from 'jest-mock';
import { JestFakeTimers as FakeTimers } from '@jest/fake-timers';
import { JestEnvironment, EnvironmentContext } from '@jest/environment';
import type { Context, Script } from 'vm';
import { JSDOM } from 'jsdom';
import type { EnvironmentContext, JestEnvironment } from '@jest/environment';
import { LegacyFakeTimers, ModernFakeTimers } from '@jest/fake-timers';
import type { Config, Global } from '@jest/types';
import { ModuleMocker } from 'jest-mock';
declare type Win = Window & Global.Global & {
Error: {
stackTraceLimit: number;
@@ -18,7 +18,8 @@ declare type Win = Window & Global.Global & {
};
declare class JSDOMEnvironment implements JestEnvironment {
dom: JSDOM | null;
fakeTimers: FakeTimers<number> | null;
fakeTimers: LegacyFakeTimers<number> | null;
fakeTimersModern: ModernFakeTimers | null;
global: Win;
errorEventListener: ((event: Event & {
error: Error;
@@ -27,7 +28,7 @@ declare class JSDOMEnvironment implements JestEnvironment {
constructor(config: Config.ProjectConfig, options?: EnvironmentContext);
setup(): Promise<void>;
teardown(): Promise<void>;
runScript(script: Script): any;
runScript<T = unknown>(script: Script): T | null;
getVmContext(): Context | null;
}
export = JSDOMEnvironment;
//# 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,OAAO,EAAC,MAAM,EAAC,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,aAAa,CAAC;AAE3C,OAAa,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,cAAc,IAAI,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAC,KAAK,EAAiB,MAAM,OAAO,CAAC;AAI5C,aAAK,GAAG,GAAG,MAAM,GACf,MAAM,CAAC,MAAM,GAAG;IACd,KAAK,EAAE;QACL,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH,CAAC;AAEJ,cAAM,gBAAiB,YAAW,eAAe;IAC/C,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC;IAClB,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACtC,MAAM,EAAE,GAAG,CAAC;IACZ,kBAAkB,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG;QAAC,KAAK,EAAE,KAAK,CAAA;KAAC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACrE,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;gBAEtB,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,OAAO,GAAE,kBAAuB;IAgE1E,KAAK;IAIL,QAAQ;IAoBR,SAAS,CAAC,MAAM,EAAE,MAAM;CAMzB;AAED,SAAS,gBAAgB,CAAC"}

View File

@@ -1,19 +1,9 @@
'use strict';
function _jestUtil() {
const data = require('jest-util');
function _jsdom() {
const data = require('jsdom');
_jestUtil = function _jestUtil() {
return data;
};
return data;
}
function _jestMock() {
const data = _interopRequireDefault(require('jest-mock'));
_jestMock = function _jestMock() {
_jsdom = function () {
return data;
};
@@ -23,43 +13,31 @@ function _jestMock() {
function _fakeTimers() {
const data = require('@jest/fake-timers');
_fakeTimers = function _fakeTimers() {
_fakeTimers = function () {
return data;
};
return data;
}
function _jsdom() {
const data = require('jsdom');
function _jestMock() {
const data = require('jest-mock');
_jsdom = function _jsdom() {
_jestMock = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _jestUtil() {
const data = require('jest-util');
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(
Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
})
);
}
ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
});
}
return target;
_jestUtil = function () {
return data;
};
return data;
}
function _defineProperty(obj, key, value) {
@@ -82,31 +60,31 @@ class JSDOMEnvironment {
_defineProperty(this, 'fakeTimers', void 0);
_defineProperty(this, 'fakeTimersModern', void 0);
_defineProperty(this, 'global', void 0);
_defineProperty(this, 'errorEventListener', void 0);
_defineProperty(this, 'moduleMocker', void 0);
this.dom = new (_jsdom()).JSDOM(
'<!DOCTYPE html>',
_objectSpread(
{
pretendToBeVisual: true,
runScripts: 'dangerously',
url: config.testURL,
virtualConsole: new (_jsdom()).VirtualConsole().sendTo(
options.console || console
)
},
config.testEnvironmentOptions
)
);
this.dom = new (_jsdom().JSDOM)('<!DOCTYPE html>', {
pretendToBeVisual: true,
runScripts: 'dangerously',
url: config.testURL,
virtualConsole: new (_jsdom().VirtualConsole)().sendTo(
options.console || console
),
...config.testEnvironmentOptions
});
const global = (this.global = this.dom.window.document.defaultView);
if (!global) {
throw new Error('JSDOM did not return a Window object');
} // Node's error-message stack size is limited at 10, but it's pretty useful
} // In the `jsdom@16`, ArrayBuffer was not added to Window, ref: https://github.com/jsdom/jsdom/commit/3a4fd6258e6b13e9cf8341ddba60a06b9b5c7b5b
// Install ArrayBuffer to Window to fix it. Make sure the test is passed, ref: https://github.com/facebook/jest/pull/7626
global.ArrayBuffer = ArrayBuffer; // Node's error-message stack size is limited at 10, but it's pretty useful
// to see more than that when a test fails.
this.global.Error.stackTraceLimit = 100;
@@ -125,7 +103,7 @@ class JSDOMEnvironment {
const originalRemoveListener = global.removeEventListener;
let userErrorListenerCount = 0;
global.addEventListener = function(...args) {
global.addEventListener = function (...args) {
if (args[0] === 'error') {
userErrorListenerCount++;
}
@@ -133,7 +111,7 @@ class JSDOMEnvironment {
return originalAddListener.apply(this, args);
};
global.removeEventListener = function(...args) {
global.removeEventListener = function (...args) {
if (args[0] === 'error') {
userErrorListenerCount--;
}
@@ -141,28 +119,34 @@ class JSDOMEnvironment {
return originalRemoveListener.apply(this, args);
};
this.moduleMocker = new (_jestMock()).default.ModuleMocker(global);
this.moduleMocker = new (_jestMock().ModuleMocker)(global);
const timerConfig = {
idToRef: id => id,
refToId: ref => ref
};
this.fakeTimers = new (_fakeTimers()).JestFakeTimers({
this.fakeTimers = new (_fakeTimers().LegacyFakeTimers)({
config,
global: global,
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();
}
if (this.global) {
if (this.errorEventListener) {
this.global.removeEventListener('error', this.errorEventListener);
@@ -174,17 +158,25 @@ class JSDOMEnvironment {
this.global.close();
}
this.errorEventListener = null; // @ts-ignore
this.errorEventListener = null; // @ts-expect-error
this.global = null;
this.dom = null;
this.fakeTimers = null;
return Promise.resolve();
this.fakeTimersModern = null;
}
runScript(script) {
if (this.dom) {
return this.dom.runVMScript(script);
return script.runInContext(this.dom.getInternalVMContext());
}
return null;
}
getVmContext() {
if (this.dom) {
return this.dom.getInternalVMContext();
}
return null;