cover-child-process
NPM module to collect coverage data from tests that need to spawn NodeJS child processes. Eg. end to end tests and/or tests on command line interfaces
Implements spawn
and exec
functions that wrap a target NodeJS script that has already been instrumented for coverage data, collects the coverage data and merges it with the coverage data already collected in the parent process.
Currently only supports files instrumented with Blanket. However, plugins for other similar instrumentation implementations can easily be created following the interface used for Blanket.
Usage
Install and save to your devDependencies
npm install --save-dev cover-child-process
Use as you would the standard child_process.exec
and child_process.spawn
methods.
#exec
var ChildProcess = ChildProcess;var Blanket = Blanket; // Use the constructor to tell the library how the source has been instrumentedvar childProcess = ; var child = childProcess;
NB. If the command does not begin with node
then it will be passed directly to child_process
without capturing coverage data
#spawn
var ChildProcess = ChildProcess;var Blanket = Blanket; // Use the constructor to tell the library how the source has been instrumentedvar childProcess = ; var server = childProcess; serverstdout;
NB. If the supplied command is not node
then it will be passed directly to child_process
without capturing coverage data
NNB. The spawned process must be killed with the default SIGTERM
signal for the coverage data to be collected
License
Copyright © 2014 Peter Halliday
Licensed under the MIT license.