0.1.0 • Published 4 years ago

logue v0.1.0

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
4 years ago

logue

npm npm: total downloads Actions Status: test

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.