Socket
Socket
Sign inDemoInstall

@testing-library/dom

Package Overview
Dependencies
Maintainers
16
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@testing-library/dom - npm Package Compare versions

Comparing version 7.31.2 to 8.0.0-alpha.1

83

dist/helpers.js

@@ -8,84 +8,23 @@ "use strict";

exports.getDocument = getDocument;
exports.runWithRealTimers = runWithRealTimers;
exports.checkContainerType = checkContainerType;
exports.jestFakeTimersAreEnabled = jestFakeTimersAreEnabled;
exports.TEXT_NODE = exports.setTimeout = exports.setImmediate = exports.clearTimeout = void 0;
const globalObj = typeof window === 'undefined' ? global : window; // Constant node.nodeType for text nodes, see:
exports.TEXT_NODE = void 0;
// Constant node.nodeType for text nodes, see:
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#Node_type_constants
const TEXT_NODE = 3; // Currently this fn only supports jest timers, but it could support other test runners in the future.
const TEXT_NODE = 3;
exports.TEXT_NODE = TEXT_NODE;
function runWithRealTimers(callback) {
return hasJestTimers() ? runWithJestRealTimers(callback).callbackReturnValue : // istanbul ignore next
callback();
}
function hasJestTimers() {
return typeof jest !== 'undefined' && jest !== null && typeof jest.useRealTimers === 'function';
}
function runWithJestRealTimers(callback) {
const timerAPI = {
clearInterval,
clearTimeout,
setInterval,
setTimeout
}; // For more on why we have the check here,
// checkout https://github.com/testing-library/dom-testing-library/issues/914
if (typeof setImmediate === 'function') {
timerAPI.setImmediate = setImmediate;
}
if (typeof clearImmediate === 'function') {
timerAPI.clearImmediate = clearImmediate;
}
jest.useRealTimers();
const callbackReturnValue = callback();
const usedFakeTimers = Object.entries(timerAPI).some(([name, func]) => func !== globalObj[name]);
if (usedFakeTimers) {
var _timerAPI$setTimeout;
jest.useFakeTimers((_timerAPI$setTimeout = timerAPI.setTimeout) != null && _timerAPI$setTimeout.clock ? 'modern' : 'legacy');
}
return {
callbackReturnValue,
usedFakeTimers
};
}
function jestFakeTimersAreEnabled() {
return hasJestTimers() ? runWithJestRealTimers(() => {}).usedFakeTimers : // istanbul ignore next
false;
} // we only run our tests in node, and setImmediate is supported in node.
// istanbul ignore next
/* istanbul ignore else */
if (typeof jest !== 'undefined' && jest !== null) {
return (// legacy timers
setTimeout._isMockFunction === true || // modern timers
Object.prototype.hasOwnProperty.call(setTimeout, 'clock')
);
} // istanbul ignore next
function setImmediatePolyfill(fn) {
return globalObj.setTimeout(fn, 0);
return false;
}
function getTimeFunctions() {
// istanbul ignore next
return {
clearTimeoutFn: globalObj.clearTimeout,
setImmediateFn: globalObj.setImmediate || setImmediatePolyfill,
setTimeoutFn: globalObj.setTimeout
};
}
const {
clearTimeoutFn,
setImmediateFn,
setTimeoutFn
} = runWithRealTimers(getTimeFunctions);
exports.setTimeout = setTimeoutFn;
exports.setImmediate = setImmediateFn;
exports.clearTimeout = clearTimeoutFn;
function getDocument() {

@@ -92,0 +31,0 @@ /* istanbul ignore if */

@@ -147,16 +147,2 @@ "use strict";

var _waitForDomChange = require("./wait-for-dom-change");
Object.keys(_waitForDomChange).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _waitForDomChange[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _waitForDomChange[key];
}
});
});
var _matches = require("./matches");

@@ -163,0 +149,0 @@

25

dist/wait-for.js

@@ -7,3 +7,2 @@ "use strict";

exports.waitFor = waitForWrapper;
exports.wait = wait;

@@ -45,3 +44,3 @@ var _helpers = require("./helpers");

let promiseStatus = 'idle';
const overallTimeoutTimer = (0, _helpers.setTimeout)(handleTimeout, timeout);
const overallTimeoutTimer = setTimeout(handleTimeout, timeout);
const usingJestFakeTimers = (0, _helpers.jestFakeTimersAreEnabled)();

@@ -80,3 +79,6 @@

await new Promise(r => (0, _helpers.setImmediate)(r));
await new Promise(r => {
setTimeout(r, 0);
jest.advanceTimersByTime(0);
});
}

@@ -102,3 +104,3 @@ } else {

finished = true;
(0, _helpers.clearTimeout)(overallTimeoutTimer);
clearTimeout(overallTimeoutTimer);

@@ -183,17 +185,2 @@ if (!usingJestFakeTimers) {

}
let hasWarned = false; // deprecated... TODO: remove this method. We renamed this to `waitFor` so the
// code people write reads more clearly.
function wait(...args) {
// istanbul ignore next
const [first = () => {}, ...rest] = args;
if (!hasWarned) {
hasWarned = true;
console.warn(`\`wait\` has been deprecated and replaced by \`waitFor\` instead. In most cases you should be able to find/replace \`wait\` with \`waitFor\`. Learn more: https://testing-library.com/docs/dom-testing-library/api-async#waitfor.`);
}
return waitForWrapper(first, ...rest);
}
/*

@@ -200,0 +187,0 @@ eslint

{
"name": "@testing-library/dom",
"version": "7.31.2",
"version": "8.0.0-alpha.1",
"description": "Simple and complete DOM testing utilities that encourage good testing practices.",

@@ -47,3 +47,3 @@ "main": "dist/index.js",

"chalk": "^4.1.0",
"dom-accessibility-api": "^0.5.6",
"dom-accessibility-api": "^0.5.5",
"lz-string": "^1.4.4",

@@ -50,0 +50,0 @@ "pretty-format": "^26.6.2"

@@ -15,3 +15,2 @@ // TypeScript Version: 3.8

export * from './wait-for'
export * from './wait-for-dom-change'
export * from './wait-for-element'

@@ -18,0 +17,0 @@ export * from './wait-for-element-to-be-removed'

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc