command-line-test

1.0.10 • Public • Published

command-line-test

NPM version build status Test coverage node version npm download

command-line test tool for Node.js

Installment

$ npm i command-line-test --save-dev

Usage

fork, spawn, exec, execFile supported.

const CliTest = require('command-line-test');
 
describe('test', function() {
  it('constructor should be ok', function() {
    CliTest.should.be.ok();
  });
 
  it('exec method should be ok with yeild', function *() {
    const cliTest = new CliTest();
    const res = yield cliTest.exec('cat package.json');
    /**
    * res return
    * {
    *   error,
    *   stdout,
    *   stderr
    * }
    */
    const _pkg = JSON.parse(res.stdout);
    pkg.name.should.be.equal(_pkg.name);
  });
 
  it('exec method should be ok with promise', function(done) {
    const cliTest1 = new CliTest();
    cliTest1.exec('cat package.json').then(res => {
      const _pkg = JSON.parse(res.stdout);
      pkg.name.should.be.equal(_pkg.name);
      done();
    });
  });
 
  it('exec method should be ok with callback', function(done) {
    const cliTest1 = new CliTest();
    cliTest1.exec('cat package.json', function(err, res) {
      const _pkg = JSON.parse(res.stdout);
      pkg.name.should.be.equal(_pkg.name);
      done();
    });
  });
});

Sample

License

The MIT License (MIT)

Readme

Keywords

Package Sidebar

Install

npm i command-line-test

Weekly Downloads

1,462

Version

1.0.10

License

MIT

Last publish

Collaborators

  • xudafeng