npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tonygo/clix

v0.0.4

Published

Write acceptance tests easily for your CLI program.

Downloads

3

Readme

⚠️: This package doesn't exist at the moment. It's only a spike made with a Readme driven development approach.

👉: Share your feedback in this issue.

⭐️ Features

  • 🏎 CLI Runner out of the box
  • 🌈 Simple API
  • 🔄 Async/Await based
  • 🌝 Test runner agnostic

📦 Install

npm install -D @tonygo/clix

🧰 Use clix

Let's write your first acceptance tests

Basic scenario

import assert from 'assert';
import clix from '@tonygo/clix';

const scenario_1 = clix('my command')
  .expect('Hey user, what is your name?')
  .input('tony')
  .expect('Super!', { timeout: 3000 });

const result_1 = await scenario_1.run();
assert.ok(result_1.ok);

Catch failure

const scenario_2 = clix('my command')
  .expect('Hey user, what is your name?')
  .input(223)
  .expectError('Sorry, dude!')
  .withCode(2);

const result_2 = await scenario_2.run();
assert.ok(result_2.ok);

Handle list

const scenario_3 = clix('my command')
  .expect([ // Handle multiple lines with arrays
    'What is your choice?',
    /a/,
    /b/
  ])
  .select([1]) // using an array for multiple choices
  .expect('Ok, dude!');

const result_2 = await scenario_3.run();
assert.ok(result_2.ok);

🗺 Road map

| Item | Status | Notes' | |-----------|-------------------|-----------------| | .select API | ABORTED | Findings here: https://github.com/tony-go/clix/issues/16 | | .skip(numberOfLines) PI | TODO | |

📖 API

scenario = clix(command: string, options: ClixOptions): Clix

Start a clix scenario with clix('my command');

Options:

interface ClixOptions {
  timeout: number;
}

scenario.expect(line: string | Regexp | (string | Regexp)[], options?: ExpectOptions): Clix

Assert that the output line (stdout) is strictly equal and returns the Clix instance.

interface ExpectOptions {
  timeout?: number;
}

scenario.expectError(errorMessage: string | Regexp | (string | Regexp)[], options?: ExpectErrorOptions): Clix

Assert that the output line (stderr) is strictly equal and returns the Clix instance.

interface ExpectErrorOptions {
  code?: number;
  timeout?: number;
}

scenario.input(input: string): Clix

Emulate an interaction with the CLI and returns the Clix instance.

async scenario.run(): Promise

Will run the program and will assert all assertions registered before.

The ClixResult object stand for:

interface ClixResult {
  ok: boolean
  acts: {
    all: () => []Act
    failed: () => Act | null
  }
}

type ActType = 'expect' | 'expect-error' | 'exit-code' | 'input';
interface Act<Value> {
  type: ActType;
  val: Value;
  ok: boolean;
  actual?: Value;
}

💪🏼 Contributing

Are interested in contributing? 😍 Please read the contribution guide first.