Skip to content

Commit b2ce847

Browse files
committed
use original
1 parent d92aea4 commit b2ce847

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

packages/codegen/src/runner.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async function sleep(ms: number): Promise<void> {
1313
async function waitFor(fn: () => void) {
1414
return new Promise<void>((resolve, reject) => {
1515
let error: unknown = null;
16-
const intervalTimer = setInterval(() => {
16+
function runFn() {
1717
try {
1818
fn();
1919
clearInterval(intervalTimer);
@@ -22,6 +22,10 @@ async function waitFor(fn: () => void) {
2222
} catch (e) {
2323
error = e;
2424
}
25+
}
26+
runFn(); // First, execute immediately
27+
const intervalTimer = setInterval(() => {
28+
runFn();
2529
}, 50);
2630
const timeoutTimer = setTimeout(() => {
2731
clearInterval(intervalTimer);
@@ -68,7 +72,7 @@ describe('runCMKInWatchMode', () => {
6872
console.log('update file');
6973
await writeFile(textFilePath, '1');
7074
const startTime = Date.now();
71-
await vi.waitFor(() => {
75+
await waitFor(() => {
7276
console.log('elapsed', Date.now() - startTime);
7377
assert(globalThis.changeCount === 1, `Expected changeCount to be 1, but got ${globalThis.changeCount}`);
7478
});

0 commit comments

Comments
 (0)