MCPcopy
hub / github.com/vitest-dev/vitest / waitForOutput

Method waitForOutput

test/test-utils/cli.ts:72–98  ·  view source on GitHub ↗
(expected: string, source: Source, caller: Parameters<typeof Error.captureStackTrace>[1])

Source from the content-addressed store, hash-verified

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
101function isWritable(stream: any): stream is Writable {

Callers 2

waitForStdoutMethod · 0.95
waitForStderrMethod · 0.95

Calls 2

resolveFunction · 0.50
rejectFunction · 0.50

Tested by

no test coverage detected