(
process: ReturnType<typeof spawn>,
message,
timeout = 10000,
)
| 14 | let replProcess: ReturnType<typeof spawn>; |
| 15 | |
| 16 | function waitForReplToStart( |
| 17 | process: ReturnType<typeof spawn>, |
| 18 | message, |
| 19 | timeout = 10000, |
| 20 | ): Promise<void> { |
| 21 | return new Promise((resolve, reject) => { |
| 22 | const timer = setTimeout(() => { |
| 23 | reject(new Error('REPL did not start in time')); |
| 24 | }, timeout); |
| 25 | |
| 26 | if (!process.stdout || !process.stderr) { |
| 27 | return reject(new Error('REPL stdout or stderr is not available')); |
| 28 | } |
| 29 | process.stdout.on('data', data => { |
| 30 | if (data.toString().includes(message)) { |
| 31 | clearTimeout(timer); |
| 32 | resolve(); |
| 33 | } |
| 34 | }); |
| 35 | |
| 36 | process.stderr.on('data', data => { |
| 37 | if (data.toString().includes(message)) { |
| 38 | clearTimeout(timer); |
| 39 | reject(new Error(`REPL started with error: ${data}`)); |
| 40 | } |
| 41 | }); |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | beforeEach(async function () { |
| 46 | this.timeout(15000); |
no test coverage detected