Updating NPM dependencies
This commit is contained in:
161
node_modules/@jest/core/build/collectHandles.js
generated
vendored
161
node_modules/@jest/core/build/collectHandles.js
generated
vendored
@@ -6,20 +6,10 @@ Object.defineProperty(exports, '__esModule', {
|
||||
exports.default = collectHandles;
|
||||
exports.formatHandleErrors = formatHandleErrors;
|
||||
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
function asyncHooks() {
|
||||
const data = _interopRequireWildcard(require('async_hooks'));
|
||||
|
||||
_jestMessageUtil = function _jestMessageUtil() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function _jestUtil() {
|
||||
asyncHooks = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -29,7 +19,27 @@ function _jestUtil() {
|
||||
function _stripAnsi() {
|
||||
const data = _interopRequireDefault(require('strip-ansi'));
|
||||
|
||||
_stripAnsi = function _stripAnsi() {
|
||||
_stripAnsi = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestMessageUtil() {
|
||||
const data = require('jest-message-util');
|
||||
|
||||
_jestMessageUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -40,12 +50,56 @@ function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* eslint-disable local/ban-types-eventually */
|
||||
function stackIsFromUser(stack) {
|
||||
// Either the test file, or something required by it
|
||||
if (stack.includes('Runtime.requireModule')) {
|
||||
@@ -64,49 +118,60 @@ function stackIsFromUser(stack) {
|
||||
}
|
||||
|
||||
return false;
|
||||
} // Inspired by https://github.com/mafintosh/why-is-node-running/blob/master/index.js
|
||||
}
|
||||
|
||||
const alwaysActive = () => true; // Inspired by https://github.com/mafintosh/why-is-node-running/blob/master/index.js
|
||||
// Extracted as we want to format the result ourselves
|
||||
|
||||
function collectHandles() {
|
||||
const activeHandles = new Map();
|
||||
let hook;
|
||||
const hook = asyncHooks().createHook({
|
||||
destroy(asyncId) {
|
||||
activeHandles.delete(asyncId);
|
||||
},
|
||||
|
||||
try {
|
||||
const asyncHooks = require('async_hooks');
|
||||
|
||||
hook = asyncHooks.createHook({
|
||||
destroy(asyncId) {
|
||||
activeHandles.delete(asyncId);
|
||||
},
|
||||
|
||||
init: function initHook(asyncId, type) {
|
||||
if (type === 'PROMISE' || type === 'TIMERWRAP') {
|
||||
return;
|
||||
}
|
||||
|
||||
const error = new (_jestUtil()).ErrorWithStack(type, initHook);
|
||||
|
||||
if (stackIsFromUser(error.stack || '')) {
|
||||
activeHandles.set(asyncId, error);
|
||||
}
|
||||
init: function initHook(asyncId, type, _triggerAsyncId, resource) {
|
||||
if (
|
||||
type === 'PROMISE' ||
|
||||
type === 'TIMERWRAP' ||
|
||||
type === 'ELDHISTOGRAM'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
hook.enable();
|
||||
} catch (e) {
|
||||
const nodeMajor = Number(process.versions.node.split('.')[0]);
|
||||
|
||||
if (e.code === 'MODULE_NOT_FOUND' && nodeMajor < 8) {
|
||||
throw new Error(
|
||||
'You can only use --detectOpenHandles on Node 8 and newer.'
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
const error = new (_jestUtil().ErrorWithStack)(type, initHook);
|
||||
|
||||
if (stackIsFromUser(error.stack || '')) {
|
||||
let isActive;
|
||||
|
||||
if (type === 'Timeout' || type === 'Immediate') {
|
||||
if ('hasRef' in resource) {
|
||||
// Timer that supports hasRef (Node v11+)
|
||||
// @ts-expect-error: doesn't exist in v10 typings
|
||||
isActive = resource.hasRef.bind(resource);
|
||||
} else {
|
||||
// Timer that doesn't support hasRef
|
||||
isActive = alwaysActive;
|
||||
}
|
||||
} else {
|
||||
// Any other async resource
|
||||
isActive = alwaysActive;
|
||||
}
|
||||
|
||||
activeHandles.set(asyncId, {
|
||||
error,
|
||||
isActive
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
hook.enable();
|
||||
return () => {
|
||||
hook.disable();
|
||||
const result = Array.from(activeHandles.values());
|
||||
hook.disable(); // Get errors for every async resource still referenced at this moment
|
||||
|
||||
const result = Array.from(activeHandles.values())
|
||||
.filter(({isActive}) => isActive())
|
||||
.map(({error}) => error);
|
||||
activeHandles.clear();
|
||||
return result;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user