Skip to content

Commit

Permalink
Improve stream validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 17, 2019
1 parent 41cd36e commit 7c29a22
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 328 deletions.
16 changes: 11 additions & 5 deletions src/options/upstream.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Buffer } from 'buffer'
import { Stream, Readable } from 'stream'

import { multipleValidOptions } from 'jest-validate'

Expand All @@ -18,21 +17,28 @@ export const CHILD_PROCESS_OPTS = {
encoding: 'utf8',
}

// Hack to make `jest-validate` validate Streams but print them nicely
const stream = {
toJSON() {
return 'Stream'
}
}

// Examples for the `execa` options
export const EXECA_OPTS = {
extendEnv: true,
stripFinalNewline: true,
preferLocal: true,
localDir: '/home/user',
input: multipleValidOptions('input', Buffer.from('input'), new Readable()),
input: multipleValidOptions('input', Buffer.from(''), stream),
reject: true,
cleanup: true,
timeout: 5000,
buffer: true,
maxBuffer: 1e7,
// eslint-disable-next-line no-magic-numbers
killSignal: multipleValidOptions('SIGTERM', 9),
stdin: multipleValidOptions('pipe', 0, new Stream()),
stdout: multipleValidOptions('pipe', 1, new Stream()),
stderr: multipleValidOptions('pipe', 2, new Stream()),
stdin: multipleValidOptions('pipe', 0, stream),
stdout: multipleValidOptions('pipe', 1, stream),
stderr: multipleValidOptions('pipe', 2, stream),
}
Binary file modified test/snapshots/echo.js.snap
Binary file not shown.
Binary file modified test/snapshots/input.js.snap
Binary file not shown.

0 comments on commit 7c29a22

Please sign in to comment.