Skip to content

Instantly share code, notes, and snippets.

View joeythomaschaske's full-sized avatar
💻

Joseph Thomaschaske joeythomaschaske

💻
View GitHub Profile
@joeythomaschaske
joeythomaschaske / jest.setup.js
Last active May 3, 2022 03:51
sfdx-lwc-jest utility for testing async functionality
global.waitFor = (expectationFunction) => {
const MAX_WAIT = 5000;
const POLL_INTERVAL = 100;
return new Promise((resolve, reject) => {
const startTime = Date.now();
let error;
const interval = setInterval(() => {
try {
if (Date.now() - startTime < MAX_WAIT) {
expectationFunction();