New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chai-exec

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

chai-exec

Chai assertions for testing your CLI

0.0.2
Source
npm
Version published
Weekly downloads
125
104.92%
Maintainers
1
Weekly downloads
 
Created
Source

Chai Exec

Chai assertions for testing your CLI

Cross-Platform Compatibility Build Status

Coverage Status Dependencies

npm License

  • ez-spawn - Simple, consistent process spawning

Examples

const chaiExec = require("chai-exec");
const chai = require("chai");
chai.use(chaiExec);

describe("My CLI", () => {
  it("should exit with a zero exit code", () => {
    // Run your CLI
    let myCLI = chaiExec('my-cli --arg1 --arg2 "some other arg"');

    // Should syntax
    myCLI.exitCode.should.equal(0);
    myCLI.should.have.exitCode(0);
    myCLI.should.exit.with.code(0);
    myCLI.should.exit.with.a.code.that.is.below(1);
    myCLI.should.have.an.exit.code.of.at.least(0);

    // Expect sytnax
    expect(myCLI.exitCode).to.equal(0);
    expect(myCLI).to.have.exitCode(0);
    expect(myCLI).to.exit.with.code(0);
    expect(myCLI).to.exit.with.a.code.that.is.below(1);
    expect(myCLI).to.have.an.exit.code.of.at.least(0);

    // Assert syntax
    assert.equal(myCLI.exitCode, 0);
    assert.exitCode(myCLI, 0);
    assert.notExitCode(myCLI, 1);
    assert.exitCodeBetween(myCLI, 0, 1);
  });
});

Installation

Node

Install using npm:

npm install chai-exec

Then require it in your test file and register it with Chai:

const chaiExec = require("chai-exec");
const chai = require("chai");
chai.use(chaiExec);

Contributing

Contributions, enhancements, and bug-fixes are welcome! File an issue on GitHub and submit a pull request.

Building/Testing

To build/test the project locally on your computer:

  • Clone this repo
    git clone hhttps://github.com/JS-DevTools/chai-exec.git

  • Install dependencies
    npm install

  • Run the tests
    npm test

License

chai-exec is 100% free and open-source, under the MIT license. Use it however you want.

Big Thanks To

Thanks to these awesome companies for their support of Open Source developers ❤

Travis CI SauceLabs Coveralls

Keywords

chai

FAQs

Package last updated on 22 Dec 2018

Did you know?

Socket

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