Skip to content

Commit 5d907d0

Browse files
committed
fix(test): bump timeout on async ensureRepoMap tests to 30s
The 3 tests in 'ensureRepoMap (async)' time out intermittently at jest's 5s default. The async path calls 'repoMap.checkAstGrepInstalled()' and potentially 'repoMap.init()', both of which spawn the ast-grep binary. Process spawn is slow on Windows (1-3s each) so the cumulative external-binary work can push past 5s, giving false-positive timeouts. Setting an explicit 30s timeout on these tests tolerates the legitimate variability (slow Windows spawn, cold cache) without masking real hangs. The sync versions (ensureRepoMapSync) don't need the bump because they don't spawn anything. Verified: 3 consecutive runs of __tests__/docs-patterns.test.js all pass cleanly (~12s each).
1 parent b7eaf1f commit 5d907d0

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

__tests__/docs-patterns.test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,26 +908,30 @@ describe('docs-patterns', () => {
908908
});
909909

910910
describe('ensureRepoMap (async)', () => {
911+
// Async path can spawn ast-grep (checkAstGrepInstalled + init), which is
912+
// slow to start on Windows. Default 5s jest timeout is too tight.
913+
const ASYNC_TIMEOUT = 30_000;
914+
911915
test('returns unavailable when repo-map not initialized', async () => {
912916
const result = await ensureRepoMap({ cwd: testDir });
913917
expect(result.available).toBe(false);
914918
expect(result.fallbackReason).toBeTruthy();
915-
});
919+
}, ASYNC_TIMEOUT);
916920

917921
test('returns correct structure', async () => {
918922
const result = await ensureRepoMap({ cwd: testDir });
919923
expect(result).toHaveProperty('available');
920924
expect(result).toHaveProperty('map');
921925
expect(result).toHaveProperty('fallbackReason');
922-
});
926+
}, ASYNC_TIMEOUT);
923927

924928
test('does not call askUser if repo-map module not found', async () => {
925929
const askUser = jest.fn();
926930
const result = await ensureRepoMap({ cwd: testDir, askUser });
927931
// askUser should not be called when module isn't available or no ast-grep
928932
// This depends on environment, but at minimum the structure should be correct
929933
expect(result).toHaveProperty('available');
930-
});
934+
}, ASYNC_TIMEOUT);
931935
});
932936

933937
describe('findUndocumentedExports', () => {

0 commit comments

Comments
 (0)