Skip to content

docs: add CLI Testing Library to ecosystem #1300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions docs/ecosystem-cli-testing-library.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
id: ecosystem-cli-testing-library
title: cli-testing-library
---

[`CLI Testing Library`](https://github.com/crutchcorn/cli-testing-library) is a
companion library to `Testing Library` that aims to mimic the API of
`Testing Library` for testing CLI applications.

```bash npm2yarn
npm install --save-dev cli-testing-library
```

```js
import {resolve} from 'path'
import {render} from '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()
})
```

Check out
[CLI Testing Library's documentation](https://github.com/crutchcorn/cli-testing-library)
for a full list of its API.

- [CLI Testing Library on GitHub](https://github.com/crutchcorn/cli-testing-library)
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ module.exports = {
'ecosystem-query-extensions',
'ecosystem-rtl-simple-queries',
'ecosystem-testing-library-selector',
'ecosystem-cli-testing-library',
],
},
],
Expand Down