🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@zoroaster/fork

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zoroaster/fork - npm Package Compare versions

Comparing version
1.2.1
to
1.2.2
+8
-4
build/index.js

@@ -89,6 +89,10 @@ const { fork } = require('spawncommand');

const ep = stderrPre ? stderrPre(e) : e
assertForkOutput(op, props.stdout)
assertForkOutput(ep, props.stderr)
if (props.code && code != props.code)
throw new Error(`Fork exited with code ${code} != ${props.code}`)
assertForkOutput(op, props.stdout, 'stdout')
assertForkOutput(ep, props.stderr, 'stderr')
if (props.code && code != props.code) {
const err =
new Error(`Fork exited with code ${code} != ${props.code}`)
err.property = 'code'
throw err
}
}

@@ -95,0 +99,0 @@

@@ -67,8 +67,13 @@ const { deepEqual } = require('assert-diff');

const assertForkOutput = (actual, expected) => {
if (typeof expected == 'string') {
assertExpected(actual, expected)
} else if (expected) {
const a = JSON.parse(actual)
deepEqual(a, expected)
const assertForkOutput = (actual, expected, prop) => {
try {
if (typeof expected == 'string') {
assertExpected(actual, expected)
} else if (expected) {
const a = JSON.parse(actual)
deepEqual(a, expected)
}
} catch (err) {
if (prop) err.property = prop
throw err
}

@@ -75,0 +80,0 @@ }

@@ -0,1 +1,7 @@

## 23 April 2019
### [1.2.2](https://github.com/contexttesting/fork/compare/v1.2.1...v1.2.2)
- [feature] Set the assertion fail property on the error, e.g., `stdout`, `stderr` or `code`.
## 8 April 2019

@@ -2,0 +8,0 @@

{
"name": "@zoroaster/fork",
"version": "1.2.1",
"version": "1.2.2",
"description": "Test forks.",

@@ -46,17 +46,17 @@ "main": "build/index.js",

"devDependencies": {
"alamode": "^1.9.2",
"documentary": "^1.23.4",
"alamode": "^1.9.3",
"documentary": "^1.24.1",
"eslint-config-artdeco": "1.0.1",
"reloquent": "^1.2.4",
"yarn-s": "1.1.0",
"zoroaster": "^3.11.4"
"zoroaster": "^3.11.6"
},
"dependencies": {
"assert-diff": "2.0.3",
"catchment": "^3.2.3",
"catchment": "^3.3.0",
"erte": "^1.1.7",
"forkfeed": "^1.0.0",
"mismatch": "^1.1.0",
"mismatch": "^1.2.0",
"spawncommand": "^2.1.2"
}
}
+13
-13

@@ -35,18 +35,18 @@ # @zoroaster/fork

`import('child_process').ForkOptions` __<a name="type-forkoptions">`ForkOptions`</a>__
`import('child_process').ForkOptions` __<a name="type-child_processforkoptions">`child_process.ForkOptions`</a>__
__<a name="type-forkconfig">`ForkConfig`</a>__: Parameters for forking.
| Name | Type | Description | Default |
| -------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| __module*__ | _string_ | The path to the module to fork. | - |
| getArgs | _(args: string[], ...contexts?: Context[]) =&gt; string[]\|Promise.&lt;string[]>_ | The function to get arguments to pass the fork based on the parsed mask input and contexts. | - |
| getOptions | _(...contexts?: Context[]) =&gt; ForkOptions_ | The function to get options for the fork, such as `ENV` and `cwd`, based on contexts. | - |
| options | _[ForkOptions](#type-forkoptions)_ | Options for the forked processed, such as `ENV` and `cwd`. | - |
| inputs | _[RegExp, string][]_ | Inputs to push to `stdin` when `stdout` writes data. The inputs are kept on stack, and taken off the stack when the RegExp matches the written data. | - |
| stderrInputs | _[RegExp, string][]_ | Inputs to push to `stdin` when `stderr` writes data (similar to `inputs`). | - |
| log | _boolean \| {stderr: Writable, stdout: Writable}_ | Whether to pipe data from `stdout`, `stderr` to the process's streams. If an object is passed, the output will be piped to streams specified as its `stdout` and `stderr` properties. | `false` |
| includeAnswers | _boolean_ | Whether to add the answers to the `stderr` and `stdout` output. | `true` |
| stripAnsi | _boolean_ | Remove ANSI escape sequences from the `stdout` and `stderr` prior to checking of the result. | `true` |
| preprocess | _(function \| {stdout?:function, stderr?:function})_ | The function to run on `stdout` and `stderr` before comparing it to the output. Pass an object with `stdout` and `stderr` properties for individual pre-processors. | - |
| Name | Type | Description | Default |
| -------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| __module*__ | <em>string</em> | The path to the module to fork. | - |
| getArgs | <em>(args: string[], ...contexts?: Context[]) =&gt; string[]\|Promise&lt;string[]></em> | The function to get arguments to pass the fork based on the parsed mask input and contexts. | - |
| getOptions | <em>(...contexts?: Context[]) =&gt; ForkOptions</em> | The function to get options for the fork, such as `ENV` and `cwd`, based on contexts. | - |
| options | <em>ForkOptions</em> | Options for the forked processed, such as `ENV` and `cwd`. | - |
| inputs | <em>[RegExp, string][]</em> | Inputs to push to `stdin` when `stdout` writes data. The inputs are kept on stack, and taken off the stack when the RegExp matches the written data. | - |
| stderrInputs | <em>[RegExp, string][]</em> | Inputs to push to `stdin` when `stderr` writes data (similar to `inputs`). | - |
| log | <em>boolean \| {stderr: Writable, stdout: Writable}</em> | Whether to pipe data from `stdout`, `stderr` to the process's streams. If an object is passed, the output will be piped to streams specified as its `stdout` and `stderr` properties. | `false` |
| includeAnswers | <em>boolean</em> | Whether to add the answers to the `stderr` and `stdout` output. | `true` |
| stripAnsi | <em>boolean</em> | Remove ANSI escape sequences from the `stdout` and `stderr` prior to checking of the result. | `true` |
| preprocess | <em>(function \| {stdout?:function, stderr?:function})</em> | The function to run on `stdout` and `stderr` before comparing it to the output. Pass an object with `stdout` and `stderr` properties for individual pre-processors. | - |

@@ -53,0 +53,0 @@ _For example, to test the fork with the next code:_

@@ -89,6 +89,10 @@ import { fork } from 'spawncommand'

const ep = stderrPre ? stderrPre(e) : e
assertForkOutput(op, props.stdout)
assertForkOutput(ep, props.stderr)
if (props.code && code != props.code)
throw new Error(`Fork exited with code ${code} != ${props.code}`)
assertForkOutput(op, props.stdout, 'stdout')
assertForkOutput(ep, props.stderr, 'stderr')
if (props.code && code != props.code) {
const err =
new Error(`Fork exited with code ${code} != ${props.code}`)
err.property = 'code'
throw err
}
}

@@ -95,0 +99,0 @@

@@ -67,8 +67,13 @@ import { deepEqual } from 'assert-diff'

export const assertForkOutput = (actual, expected) => {
if (typeof expected == 'string') {
assertExpected(actual, expected)
} else if (expected) {
const a = JSON.parse(actual)
deepEqual(a, expected)
export const assertForkOutput = (actual, expected, prop) => {
try {
if (typeof expected == 'string') {
assertExpected(actual, expected)
} else if (expected) {
const a = JSON.parse(actual)
deepEqual(a, expected)
}
} catch (err) {
if (prop) err.property = prop
throw err
}

@@ -75,0 +80,0 @@ }