@@ -4,6 +4,8 @@ const nodeAssert = require('assert')
4
4
const os = require ( 'os' )
5
5
const split = require ( 'split2' )
6
6
7
+ const DEFAULT_WAIT_FOR_TIMEOUT = 1000
8
+
7
9
/**
8
10
* Create a Pino destination stream to easily inspect the logs processed by Pino.
9
11
*
@@ -129,4 +131,31 @@ async function consecutive (stream, expectedOrCallbacks, assert = nodeAssert.dee
129
131
}
130
132
}
131
133
134
+ /**
135
+ * Assert a specific log is expected, ignoring the rest.
136
+ *
137
+ * @param {import('node:stream').Transform } stream The stream to be tested.
138
+ * @param {Array<object | Function> } expectedsOrCallbacks The array of expected values to be tested or callback functions.
139
+ * @param {Function } [assert=nodeAssert.deepStrictEqual] The assert function to be used when the expectedOrCallback parameter is an object.
140
+ * @param {Number } [timeout=1000] The time in milliseconds to wait for the expected value.
141
+ *
142
+ * @returns A promise that resolves when the expected value is equal to the stream value.
143
+ * @throws If the expected value is not equal to the stream value.
144
+ * @throws If the callback function throws an error.
145
+ * @throws If timeout is reached.
146
+ *
147
+ * @example
148
+ * const stream = pinoTest.sink()
149
+ * const logger = pino(stream)
150
+ *
151
+ * logger.debug('setting up server')
152
+ * logger.info('server started')
153
+ * logger.error('server crashed')
154
+ *
155
+ * await pinoTest.waitFor(stream, { msg: 'server started', level: 30 })
156
+ */
157
+ async function waitFor ( stream , expectedOrCallbacks , assert = nodeAssert . deepStrictEqual , timeout = DEFAULT_WAIT_FOR_TIMEOUT ) {
158
+ // TODO implementation
159
+ }
160
+
132
161
module . exports = { sink, once, consecutive }
0 commit comments