public assertOutput()

in testSupport/src/debugClient.ts [392:418]


	public assertOutput(category: string, expected: string, timeout?: number): Promise<DebugProtocol.Event> {

		timeout = timeout || this.defaultTimeout;

		return new Promise((resolve, reject) => {
			let output = '';
			let timeoutHandler: any;
			this.on('output', event => {
				const e = <DebugProtocol.OutputEvent> event;
				if (e.body.category === category) {
					output += e.body.output;
					if (output.indexOf(expected) === 0) {
						clearTimeout(timeoutHandler);
						resolve(event);
					} else if (expected.indexOf(output) !== 0) {
						const sanitize = (s: string) => s.toString().replace(/\r/mg, '\\r').replace(/\n/mg, '\\n');
						reject(new Error(`received data '${sanitize(output)}' is not a prefix of the expected data '${sanitize(expected)}'`));
					}
				}
			});
			if (!this._socket) {	// no timeouts if debugging the tests
				timeoutHandler = setTimeout(() => {
					reject(new Error(`not enough output data received after ${timeout} ms`));
				}, timeout);
			}
		});
	}