@@ -17,7 +17,13 @@ const cli = (cmd: string) => `node ${cliPath} ${cmd}`;
1717// NOTE: These tests have implementation dependencies
1818// Simpler tests are in src/__tests__/integration/cli-integration.test.ts
1919
20- describe ( 'CLI Integration Tests' , { timeout : 60_000 } , ( ) => {
20+ // Per-command execSync timeout must be strictly less than the per-test vitest
21+ // timeout so that execSync self-aborts before vitest tries (and fails) to
22+ // interrupt the blocked event loop. 25 s per command, 30 s per single-command
23+ // test, 55 s per two-command test, 120 s suite-level cap.
24+ const EXEC_TIMEOUT = 25_000 ;
25+
26+ describe ( 'CLI Integration Tests' , { timeout : 120_000 } , ( ) => {
2127 let testDir : string ;
2228
2329 beforeEach ( ( ) => {
@@ -27,7 +33,7 @@ describe('CLI Integration Tests', { timeout: 60_000 }, () => {
2733 process . chdir ( testDir ) ;
2834
2935 // Initialize StackMemory in test directory
30- execSync ( cli ( 'init' ) , { cwd : testDir , timeout : 30000 } ) ;
36+ execSync ( cli ( 'init' ) , { cwd : testDir , timeout : EXEC_TIMEOUT } ) ;
3137
3238 // Create context.db since init skips DB creation in test mode
3339 const dbDir = path . join ( testDir , '.stackmemory' ) ;
@@ -98,7 +104,7 @@ describe('CLI Integration Tests', { timeout: 60_000 }, () => {
98104 const result = execSync ( cli ( 'clear --status' ) , {
99105 cwd : testDir ,
100106 encoding : 'utf8' ,
101- timeout : 30000 ,
107+ timeout : EXEC_TIMEOUT ,
102108 } ) ;
103109
104110 // Updated expectations to match actual output
@@ -112,7 +118,7 @@ describe('CLI Integration Tests', { timeout: 60_000 }, () => {
112118 const result = execSync ( cli ( 'capture' ) , {
113119 cwd : testDir ,
114120 encoding : 'utf8' ,
115- timeout : 30000 ,
121+ timeout : EXEC_TIMEOUT ,
116122 } ) ;
117123
118124 // Check for any successful output
@@ -126,29 +132,29 @@ describe('CLI Integration Tests', { timeout: 60_000 }, () => {
126132 }
127133 } ) ;
128134
129- it ( 'should load handoff document' , { timeout : 30000 } , ( ) => {
135+ it ( 'should load handoff document' , { timeout : 55000 } , ( ) => {
130136 // First generate a handoff
131- execSync ( cli ( 'capture' ) , { cwd : testDir , timeout : 30000 } ) ;
137+ execSync ( cli ( 'capture' ) , { cwd : testDir , timeout : EXEC_TIMEOUT } ) ;
132138
133139 // Then load it
134140 const result = execSync ( cli ( 'restore' ) , {
135141 cwd : testDir ,
136142 encoding : 'utf8' ,
137- timeout : 30000 ,
143+ timeout : EXEC_TIMEOUT ,
138144 } ) ;
139145
140146 // Just check it ran without error
141147 expect ( result ) . toBeDefined ( ) ;
142148 } ) ;
143149
144- it ( 'should capture handoff document' , { timeout : 30000 } , ( ) => {
150+ it ( 'should capture handoff document' , { timeout : 55000 } , ( ) => {
145151 // Generate a capture
146- execSync ( cli ( 'capture' ) , { cwd : testDir , timeout : 30000 } ) ;
152+ execSync ( cli ( 'capture' ) , { cwd : testDir , timeout : EXEC_TIMEOUT } ) ;
147153
148154 const result = execSync ( cli ( 'capture' ) , {
149155 cwd : testDir ,
150156 encoding : 'utf8' ,
151- timeout : 30000 ,
157+ timeout : EXEC_TIMEOUT ,
152158 } ) ;
153159
154160 // Just check it ran without error
0 commit comments