Socket
Socket
Sign inDemoInstall

cover-child-process

Package Overview
Dependencies
2
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cover-child-process

Collect coverage data from child processes


Version published
Weekly downloads
19
increased by46.15%
Maintainers
1
Install size
46.3 kB
Created
Weekly downloads
 

Readme

Source

cover-child-process

Build Status Coverage Status Dependency Status devDependency Status

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 = require('cover-child-process').ChildProcess;
var Blanket = require('cover-child-process').Blanket;

// Use the constructor to tell the library how the source has been instrumented
var childProcess = new ChildProcess(new Blanket());

var child = childProcess.exec(
  'node ../lib-cov/cli.js init something', {
    cwd: '../fixtures/test-scenario'
  }, function (error, stdout, stderr) {
    // Test output, etc, then done
  }
);

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 = require('cover-child-process').ChildProcess;
var Blanket = require('cover-child-process').Blanket;

// Use the constructor to tell the library how the source has been instrumented
var childProcess = new ChildProcess(new Blanket());

var server = childProcess.spawn(
  'node', [
    '../lib-cov/server.js',
    '8080'
  ], {
    env: process.env
  }
);

server.stdout.on('data', function (data) {
  // When server has started run tests, then kill the child process
  server.kill();
});

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.

Donate Bitcoins

17LtnRG4WxRLYBWzrBoEKP3F7fZx8vcAsK

Keywords

FAQs

Last updated on 16 Sep 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc