Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wdio-local-runner: unpipe streams in the end (#3882)
* wdio-local-runner: unpipe streams in the end * wdio-local-runner: transformStream _final test
- Loading branch information
1 parent
6e5d2a0
commit 45962bc
Showing
2 changed files
with
26 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
import RunnerTransformStream from '../src/transformStream' | ||
import { DEBUGGER_MESSAGES } from '../src/constants' | ||
|
||
jest.mock('stream', () => { | ||
class TransformMock { | ||
constructor () { | ||
this.push = jest.fn() | ||
} | ||
} | ||
|
||
return { Transform: TransformMock } | ||
}) | ||
|
||
test('should add cid to message', () => { | ||
const stream = new RunnerTransformStream('0-5') | ||
const cb = jest.fn() | ||
const pushSpy = jest.spyOn(stream, 'push') | ||
|
||
stream._transform('foobar', null, cb) | ||
expect(stream.push).toBeCalledWith('[0-5] foobar') | ||
expect(pushSpy).toBeCalledWith('[0-5] foobar') | ||
expect(cb).toBeCalled() | ||
}) | ||
|
||
test('should ignore debugger messages', () => { | ||
const stream = new RunnerTransformStream('0-5') | ||
const cb = jest.fn() | ||
const pushSpy = jest.spyOn(stream, 'push') | ||
|
||
DEBUGGER_MESSAGES.forEach(m => stream._transform(`${m} foobar`, null, cb)) | ||
expect(stream.push).toBeCalledTimes(0) | ||
expect(pushSpy).toBeCalledTimes(0) | ||
}) | ||
|
||
test('should ignore debugger messages', (done) => { | ||
const stream = new RunnerTransformStream('0-5') | ||
const stream2 = new RunnerTransformStream('0-6') | ||
|
||
stream2.pipe(stream) | ||
const cb = jest.fn() | ||
stream.on('unpipe', cb) | ||
|
||
const finalSpy = jest.spyOn(stream, '_final') | ||
|
||
stream.end(() => { | ||
expect(cb).toBeCalled() | ||
expect(finalSpy).toBeCalled() | ||
done() | ||
}) | ||
}) |