Chai Exec
Chai assertions for testing your CLI



Related Projects
- 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", () => {
let myCLI = chaiExec('my-cli --arg1 --arg2 "some other arg"');
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(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.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:
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 ❤
