1. cli-testing-library
Simple and complete CLI testing utilities that encourage good testing practices.
cli-testing-library
Package: cli-testing-library
Created by: crutchcorn
Last modified: Tue, 02 Jan 2024 00:42:39 GMT
Version: 2.0.2
License: MIT
Downloads: 1,126
Repository: https://github.com/crutchcorn/cli-testing-library

Install

npm install cli-testing-library
yarn add cli-testing-library

CLI Testing Library

koala

Simple and complete CLI testing utilities that encourage good testing practices.


Build Status
version
downloads
MIT License
PRs Welcome
Code of Conduct

All Contributors

Watch on GitHub
Star on GitHub

Table of Contents

This project is not affiliated with the
"Testing Library" ecosystem that this
project is clearly inspired from. We're just big fans :)

Installation

This module is distributed via [npm][npm] which is bundled with [node][node] and
should be installed as one of your project's devDependencies:

npm install --save-dev cli-testing-library

Usage

This is currently the only section of "usage" documentation. We'll be
expanding it as soon as possible

Usage example:

 const {resolve} = require('path')
const {render} = require('cli-testing-library')

test('Is able to make terminal input and view in-progress stdout', async () => {
  const {clear, findByText, queryByText, userEvent} = await render('node', [
    resolve(__dirname, './execute-scripts/stdio-inquirer.js'),
  ])

  const instance = await findByText('First option')

  expect(instance).toBeInTheConsole()

  expect(await findByText('❯ One')).toBeInTheConsole()

  clear()

  userEvent('[ArrowDown]')

  expect(await findByText('❯ Two')).toBeInTheConsole()

  clear()

  userEvent.keyboard('[Enter]')

  expect(await findByText('First option: Two')).toBeInTheConsole()
  expect(await queryByText('First option: Three')).not.toBeInTheConsole()
})

For a API reference documentation, including suggestions on how to use this
library, see our
documentation introduction with further reading.

While this library does work in Windows, it does not appear to function
properly in Windows CI environments, such as GitHub actions. As a result, you
may need to either switch CI systems or limit your CI to only run in Linux

If you know how to fix this, please let us know in
this tracking issue

Contributors ✨

Thanks goes to these wonderful people
(emoji key):

Corbin Crutchley
Corbin Crutchley

💻 📖 🚧
Bitcollage
Bitcollage

📖
Julien Goux
Julien Goux

🐛 💻
Cory Forsyth
Cory Forsyth

📖
eran-cohen
eran-cohen

📖

This project follows the
all-contributors
specification. Contributions of any kind welcome!

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin