logue
v0.1.0
Published
Simplest way to test your interactive command-line app.
Downloads
4
Readme
logue
The tiny yet powerful test utility for interactive command-line apps.
Install
npm i --save logue
# or
yarn add logue
Example (Jest)
import logue from "logue"
it("test", async () => {
const app = logue("./my-cli-app.js", ["put", "--args", "here"]) // spawn
await app.waitFor("continue?") // wait until "continue?" appears in stdout
expect(app.stdout).toContain("[yes/no]")
await app.input("yes") // write "yes" to stdin
await app.end() // wait for the process to be completed
expect(app.stdout).toContain("Done!")
}
Also, uou can just chain all of methods:
const result = await logue(args).waitFor("continue?").input("y").end();
expect(result.stdout).toContain("Done!");
API
Soon
Contributing
See Contribution guide.