logue

🌝 Keep your interactive command-line apps testable.

APACHE-2.0 License

Downloads
14
Stars
4
Committers
1

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, you 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.