@@ -184,6 +184,7 @@ describe('crashing', () => {
184184 it ( 'restarts service on successful pre-ready onCrash' , async ( ) => {
185185 const script = getScript ( `
186186 config.services.second.command = ['node', '-e', 'console.log("Crashing")'];
187+ config.services.second.crashesLength = 3;
187188 config.services.second.onCrash = ctx => {
188189 if (ctx.crashes.length === 3) throw new Error('Crashed three times');
189190 };
@@ -220,6 +221,7 @@ describe('crashing', () => {
220221 } )
221222 it ( 'restarts service on successful post-ready onCrash' , async ( ) => {
222223 const script = getScript ( `
224+ config.services.second.crashesLength = 2;
223225 config.services.second.logTailLength = 1;
224226 config.services.second.onCrash = async ctx => {
225227 const tests = [
@@ -282,5 +284,25 @@ describe('crashing', () => {
282284 "second | Started 🚀",
283285 ]
284286 ` )
287+
288+ // crash again
289+ expect ( await fetchText ( 'http://localhost:8002/?crash' ) ) . toBe ( 'crashing' )
290+ // allow time for restart again
291+ await delay ( 500 )
292+ // make sure it restarted again
293+ expect ( await fetchText ( 'http://localhost:8002/' ) ) . toBe ( 'second' )
294+ // correct output for 3rd crash
295+ expect ( proc . flushOutput ( ) ) . toMatchInlineSnapshot ( `
296+ Array [
297+ "second | Crashing",
298+ " (info) Service 'second' crashed",
299+ "number of crashes: 2",
300+ "crash logTail: [\\"Crashing\\\\n\\"]",
301+ "Handling crash...",
302+ "Done handling crash",
303+ " (info) Restarting service 'second'",
304+ "second | Started 🚀",
305+ ]
306+ ` )
285307 } )
286308} )
0 commit comments