All Projects → jamesgeorge007 → Cli Prompts Test

jamesgeorge007 / Cli Prompts Test

Licence: gpl-3.0
Write e2e tests for CLI apps with ease

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Cli Prompts Test

Gest
👨‍💻 A sensible GraphQL testing tool - test your GraphQL schema locally and in the cloud
Stars: ✭ 109 (+541.18%)
Mutual labels:  command-line, test, integration-testing
Javascript Testing Best Practices
📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (August 2021)
Stars: ✭ 13,976 (+82111.76%)
Mutual labels:  test, integration-testing, e2e-tests
Doitlive
Because sometimes you need to do it live
Stars: ✭ 3,073 (+17976.47%)
Mutual labels:  command-line, hacktoberfest
Codeceptjs
Supercharged End 2 End Testing Framework for NodeJS
Stars: ✭ 3,592 (+21029.41%)
Mutual labels:  hacktoberfest, e2e-tests
Venom
🐍 Manage and run your integration tests with efficiency - Venom run executors (script, HTTP Request, web, imap, etc... ) and assertions
Stars: ✭ 384 (+2158.82%)
Mutual labels:  test, integration-testing
ngx-testbedder
CLI tool for writing the test bed for Angular integration test
Stars: ✭ 13 (-23.53%)
Mutual labels:  test, integration-testing
api-test
🌿 A simple bash script to test JSON API from terminal in a structured and organized way.
Stars: ✭ 53 (+211.76%)
Mutual labels:  test, integration-testing
Castero
TUI podcast client for the terminal
Stars: ✭ 375 (+2105.88%)
Mutual labels:  command-line, hacktoberfest
Pueue
🌠 Manage your shell commands.
Stars: ✭ 2,471 (+14435.29%)
Mutual labels:  command-line, hacktoberfest
Broot
A new way to see and navigate directory trees : https://dystroy.org/broot
Stars: ✭ 6,362 (+37323.53%)
Mutual labels:  command-line, hacktoberfest
Xonsh
🐚 Python-powered, cross-platform, Unix-gazing shell
Stars: ✭ 5,327 (+31235.29%)
Mutual labels:  command-line, hacktoberfest
Faker
Faker is a pure Elixir library for generating fake data.
Stars: ✭ 673 (+3858.82%)
Mutual labels:  hacktoberfest, test
jest-retry
Jest retry pattern for flaky E2E tests
Stars: ✭ 36 (+111.76%)
Mutual labels:  test, e2e-tests
Doctl
The official command line interface for the DigitalOcean API.
Stars: ✭ 2,856 (+16700%)
Mutual labels:  command-line, hacktoberfest
Starcli
✨ Browse GitHub trending projects from your command line
Stars: ✭ 269 (+1482.35%)
Mutual labels:  command-line, hacktoberfest
Yarnhook
Run `yarn install`, `npm install` or `pnpm install` on git hooks automatically
Stars: ✭ 177 (+941.18%)
Mutual labels:  command-line, hacktoberfest
Unity Actions
Github actions for testing and building Unity projects
Stars: ✭ 358 (+2005.88%)
Mutual labels:  hacktoberfest, test
Bat
A cat(1) clone with wings.
Stars: ✭ 30,833 (+181270.59%)
Mutual labels:  command-line, hacktoberfest
Progressbar
A really basic thread-safe progress bar for Golang applications
Stars: ✭ 2,212 (+12911.76%)
Mutual labels:  command-line, hacktoberfest
Marketplace Partners
Image validation, automation, and other tools for DigitalOcean Marketplace partners and Custom Image users
Stars: ✭ 139 (+717.65%)
Mutual labels:  command-line, hacktoberfest

CLI Prompts Test

Write e2e tests for CLI apps with ease.

Installation

$ npm install --save-dev cli-prompts-test

API

runTest(args, answers, options?)

  • args: CLI args to pass in.
  • answers: answers to be passed to stdout (simulate user input).
  • options: Optionally specify the testPath (defaults to process.cwd()) and timeout (defaults to 500ms) between keystrokes.

Usage

// cli.js

const enquirer = require("enquirer");

const choices = ['First option', 'Second option', 'Third option'];

enquirer
  .prompt({
    type: "select",
    name: "option",
    message: "Choose from below",
    choices,
  })
  .then(({ option }) => {
    console.log(`You chose ${option}`);
  });
// test.js

const runTest, { DOWN, ENTER } = require("cli-prompts-test");

const cliPath = `${__dirname}/cli.js`;

describe("cli-prompts-test", () => {
  it("picks first option", async () => {
    const { exitCode, stdout } = await runTest(
      [cliPath],
      [ENTER]
    );

    // Assertions
    expect(exitCode).toBe(0);
    expect(stdout).toContain("You chose First option");
  });

  it("picks second option", async () => {
    const { exitCode, stdout } = await runTest(
      [cliPath],
      [`${DOWN}${ENTER}`]
    );

    // Assertions
    expect(exitCode).toBe(0);
    expect(stdout).toContain("You chose Second option");
  });

  it("picks third option", async () => {
    const { exitCode, stdout } = await runTest(
      [cliPath],
      [`${DOWN}${DOWN}${ENTER}`]
    );

    // Assertions
    expect(exitCode).toBe(0);
    expect(stdout).toContain("You chose Third option");
  });
});

Find an example here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].