sapling/addons/shared/testUtils.ts
Evan Krause a42bd5fa1f Include UI state in bug reports
Reviewed By: quark-zju

Differential Revision: D43139551

fbshipit-source-id: 08bc2c370c5f6519bd0602abadedf7fe20b2da4d
2023-02-09 18:37:31 -08:00

29 lines
718 B
TypeScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type {Logger} from '../isl-server/src/logger';
import type {Json} from './typeUtils';
export const mockLogger: Logger = {
log: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
};
export function clone<T extends Json>(o: T): T {
return JSON.parse(JSON.stringify(o));
}
/**
* Returns a Promise which resolves after the current async tick is finished.
* Useful for testing code which `await`s.
*/
export function nextTick(): Promise<void> {
return new Promise(res => setTimeout(res, 0));
}