(expected: string, source: Source, caller: Parameters<typeof Error.captureStackTrace>[1])
| 70 | } |
| 71 | |
| 72 | private waitForOutput(expected: string, source: Source, caller: Parameters<typeof Error.captureStackTrace>[1]) { |
| 73 | const error = new Error('Timeout') |
| 74 | Error.captureStackTrace(error, caller) |
| 75 | |
| 76 | return new Promise<void>((resolve, reject) => { |
| 77 | if (this[source].includes(expected)) { |
| 78 | return resolve() |
| 79 | } |
| 80 | |
| 81 | const timeout = setTimeout(() => { |
| 82 | error.message = `Timeout when waiting for error "${expected}".\nReceived:\nstdout: ${this.stdout}\nstderr: ${this.stderr}` |
| 83 | reject(error) |
| 84 | }, process.env.CI ? 20_000 : 4_000) |
| 85 | |
| 86 | const listener = () => { |
| 87 | if (this[source].includes(expected)) { |
| 88 | if (timeout) { |
| 89 | clearTimeout(timeout) |
| 90 | } |
| 91 | |
| 92 | resolve() |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | this[`${source}Listeners`].push(listener) |
| 97 | }) |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | function isWritable(stream: any): stream is Writable { |
no test coverage detected