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

@testing-library/react-hooks

Package Overview
Dependencies
Maintainers
16
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@testing-library/react-hooks - npm Package Compare versions

Comparing version 4.0.0-beta.2 to 4.0.0

42

lib/asyncUtils.js

@@ -11,4 +11,4 @@ "use strict";

class TimeoutError extends Error {
constructor(utilName, timeout) {
super(`Timed out in ${utilName} after ${timeout}ms.`);
constructor(util, timeout) {
super(`Timed out in ${util.name} after ${timeout}ms.`);
}

@@ -35,3 +35,3 @@

if (timeout && timeout > 0) {
timeoutId = setTimeout(() => reject(new TimeoutError('waitForNextUpdate', timeout)), timeout);
timeoutId = setTimeout(() => reject(new TimeoutError(waitForNextUpdate, timeout)), timeout);
}

@@ -88,3 +88,3 @@

if (error instanceof TimeoutError && initialTimeout) {
throw new TimeoutError('waitFor', initialTimeout);
throw new TimeoutError(waitFor, initialTimeout);
}

@@ -104,22 +104,24 @@

return {
waitFor,
waitForNextUpdate,
waitForValueToChange: async (selector, options = {}) => {
const initialValue = selector();
const waitForValueToChange = async (selector, options = {}) => {
const initialValue = selector();
try {
await waitFor(() => selector() !== initialValue, {
suppressErrors: false,
...options
});
} catch (error) {
if (error instanceof TimeoutError && options.timeout) {
throw new TimeoutError('waitForValueToChange', options.timeout);
}
try {
await waitFor(() => selector() !== initialValue, {
suppressErrors: false,
...options
});
} catch (error) {
if (error instanceof TimeoutError && options.timeout) {
throw new TimeoutError(waitForValueToChange, options.timeout);
}
throw error;
}
throw error;
}
};
return {
waitFor,
waitForNextUpdate,
waitForValueToChange
};
}

@@ -126,0 +128,0 @@

{
"name": "@testing-library/react-hooks",
"version": "4.0.0-beta.2",
"version": "4.0.0",
"description": "Simple and complete React hooks testing utilities that encourage good testing practices.",

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

@@ -10,4 +10,4 @@ import { act } from 'react-test-renderer'

class TimeoutError extends Error {
constructor(utilName: string, timeout: number) {
super(`Timed out in ${utilName} after ${timeout}ms.`)
constructor(util: Function, timeout: number) {
super(`Timed out in ${util.name} after ${timeout}ms.`)
}

@@ -31,3 +31,3 @@ }

timeoutId = setTimeout(
() => reject(new TimeoutError('waitForNextUpdate', timeout)),
() => reject(new TimeoutError(waitForNextUpdate, timeout)),
timeout

@@ -79,3 +79,3 @@ )

if (error instanceof TimeoutError && initialTimeout) {
throw new TimeoutError('waitFor', initialTimeout)
throw new TimeoutError(waitFor, initialTimeout)
}

@@ -102,3 +102,3 @@ throw error as Error

if (error instanceof TimeoutError && options.timeout) {
throw new TimeoutError('waitForValueToChange', options.timeout)
throw new TimeoutError(waitForValueToChange, options.timeout)
}

@@ -105,0 +105,0 @@ throw error as Error

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