logue
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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.

Package Sidebar

Install

npm i logue

Weekly Downloads

1

Version

0.1.0

License

Apache-2.0

Unpacked Size

16.1 kB

Total Files

5

Last publish

Collaborators

  • uetchy