Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crutchcorn/cli-testing-library
🐨 Simple and complete CLI testing utilities that encourage good testing practices.
https://github.com/crutchcorn/cli-testing-library
Last synced: 9 days ago
JSON representation
🐨 Simple and complete CLI testing utilities that encourage good testing practices.
- Host: GitHub
- URL: https://github.com/crutchcorn/cli-testing-library
- Owner: crutchcorn
- License: mit
- Created: 2021-10-19T00:56:40.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-02T00:42:36.000Z (about 1 year ago)
- Last Synced: 2024-05-02T23:32:25.190Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 278 KB
- Stars: 75
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
CLI Testing Library
Simple and complete CLI testing utilities that encourage good testing
practices.
[](https://github.com/crutchcorn/cli-testing-library/actions/workflows/validate.yml?query=branch%3Amain)
[](https://www.npmjs.com/package/cli-testing-library)
[](https://www.npmjs.com/package/cli-testing-library)
[](./LICENSE)
[](makeapullrequest.com)
[](./CODE_OF_CONDUCT.md)[](#contributors-)
[](https://github.com/crutchcorn/cli-testing-library/watchers)
[](https://github.com/crutchcorn/cli-testing-library/stargazers)## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Contributors ✨](#contributors-)> This project is not affiliated with the
> ["Testing Library"](https://github.com/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 possibleUsage example:
```javascript
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](https://cli-testing.com/guides/introduction/).> 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](https://github.com/crutchcorn/cli-testing-library/issues/3)