import execa from 'execa' ; import { watchStdioForLine } from '../watch_stdio_for_line' ; const onLogLine = jest . fn ( ) ; beforeEach ( ( ) => { jest . clearAllMocks ( ) ; } ) ; it ( 'calls logFn with log lines' , async ( ) => { const proc = execa ( process . execPath , [ '-e' , 'console.log("hi")' ] ) ; await watchStdioForLine ( proc , onLogLine ) ; expect ( onLogLine . mock . calls ) . toMatchInlineSnapshot ( `
    Array [
      Array [
        "hi",
      ],
    ]
  ` ) ; } ) ; it ( 'send the proc SIGKILL if it logs a line matching exitAfter regexp' , async function ( ) { const proc = execa ( process . execPath , [ require . resolve ( '../__fixtures__/log_on_sigint' ) ] ) ; await watchStdioForLine ( proc , onLogLine , /listening for SIGINT/ ) ; expect ( onLogLine . mock . calls ) . toMatchInlineSnapshot ( `
    Array [
      Array [
        "listening for SIGINT",
      ],
    ]
  ` ) ; } ) ;