fix(editor): Fix ts errors in PersonalizationModal.spec.ts (no-changelog) (#9562)
This commit is contained in:
@@ -4,10 +4,15 @@ import type { ISettingsState } from '@/Interface';
|
||||
import { UserManagementAuthenticationMethod } from '@/Interface';
|
||||
import { defaultSettings } from './defaults';
|
||||
|
||||
export const retry = async (
|
||||
assertion: () => ReturnType<typeof expect>,
|
||||
{ interval = 20, timeout = 1000 } = {},
|
||||
) => {
|
||||
/**
|
||||
* Retries the given assertion until it passes or the timeout is reached
|
||||
*
|
||||
* @example
|
||||
* await retry(
|
||||
* () => expect(screen.getByText('Hello')).toBeInTheDocument()
|
||||
* );
|
||||
*/
|
||||
export const retry = async (assertion: () => void, { interval = 20, timeout = 1000 } = {}) => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
const startTime = Date.now();
|
||||
|
||||
@@ -15,9 +20,9 @@ export const retry = async (
|
||||
setTimeout(() => {
|
||||
try {
|
||||
resolve(assertion());
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
if (Date.now() - startTime > timeout) {
|
||||
reject(err);
|
||||
reject(error);
|
||||
} else {
|
||||
tryAgain();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user