Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wait-for-expect

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wait-for-expect - npm Package Compare versions

Comparing version 1.3.0 to 2.0.0

16

lib/index.js

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

exports.default = void 0;
// Used to avoid using Jest's fake timers and Date.now mocks
// See https://github.com/TheBrainFamily/wait-for-expect/issues/4 and
// https://github.com/TheBrainFamily/wait-for-expect/issues/12 for more info
var _ref = typeof window !== "undefined" ? window : global,
setTimeout = _ref.setTimeout;
var defaults = {

@@ -31,3 +24,10 @@ timeout: 4500,

var interval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaults.interval;
// eslint-disable-next-line no-param-reassign
// Used to avoid using Jest's fake timers and Date.now mocks
// See https://github.com/TheBrainFamily/wait-for-expect/issues/4 and
// https://github.com/TheBrainFamily/wait-for-expect/issues/12 for more info
var _ref = typeof window !== "undefined" ? window : global,
setTimeout = _ref.setTimeout; // eslint-disable-next-line no-param-reassign
if (interval < 1) interval = 1;

@@ -34,0 +34,0 @@ var maxTries = Math.ceil(timeout / interval);

@@ -15,6 +15,7 @@ "use strict";

beforeEach(function () {
jest.resetModules();
jest.restoreAllMocks();
jest.useRealTimers();
});
test("it works even if the timers are overwritten by jest",
test("it works with real timers even if they were set to fake before importing the module",
/*#__PURE__*/

@@ -24,3 +25,3 @@ _asyncToGenerator(

regeneratorRuntime.mark(function _callee() {
var numberToChange, randomTimeout;
var importedWaitForExpect, numberToChange, randomTimeout;
return regeneratorRuntime.wrap(function _callee$(_context) {

@@ -31,2 +32,6 @@ while (1) {

jest.useFakeTimers();
/* eslint-disable global-require */
importedWaitForExpect = require("./index");
jest.useRealTimers();
numberToChange = 10; // we are using random timeout here to simulate a real-time example

@@ -39,9 +44,8 @@ // of an async operation calling a callback at a non-deterministic time

}, randomTimeout);
jest.runAllTimers();
_context.next = 7;
return (0, _index.default)(function () {
_context.next = 8;
return importedWaitForExpect(function () {
expect(numberToChange).toEqual(100);
});
case 7:
case 8:
case "end":

@@ -48,0 +52,0 @@ return _context.stop();

{
"name": "wait-for-expect",
"version": "1.3.0",
"version": "2.0.0",
"description": "Wait for expectation to be true, useful for integration and end to end testing",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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