xudafeng / command-line-test

command-line test tool for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)

About

command-line test tool for Node.js


Languages

Language:JavaScript 91.5%Language:Makefile 8.5%