Skip to content

Commit d99eadb

Browse files
authored
docs: add CLI Testing Library to ecosystem (#1300)
1 parent c20f8a8 commit d99eadb

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
id: ecosystem-cli-testing-library
3+
title: cli-testing-library
4+
---
5+
6+
[`CLI Testing Library`](https://github.com/crutchcorn/cli-testing-library) is a
7+
companion library to `Testing Library` that aims to mimic the API of
8+
`Testing Library` for testing CLI applications.
9+
10+
```bash npm2yarn
11+
npm install --save-dev cli-testing-library
12+
```
13+
14+
```js
15+
import {resolve} from 'path'
16+
import {render} from 'cli-testing-library'
17+
18+
test('Is able to make terminal input and view in-progress stdout', async () => {
19+
const {clear, findByText, queryByText, userEvent} = await render('node', [
20+
resolve(__dirname, './execute-scripts/stdio-inquirer.js'),
21+
])
22+
23+
const instance = await findByText('First option')
24+
25+
expect(instance).toBeInTheConsole()
26+
27+
expect(await findByText('❯ One')).toBeInTheConsole()
28+
29+
clear()
30+
31+
userEvent('[ArrowDown]')
32+
33+
expect(await findByText('❯ Two')).toBeInTheConsole()
34+
35+
clear()
36+
37+
userEvent.keyboard('[Enter]')
38+
39+
expect(await findByText('First option: Two')).toBeInTheConsole()
40+
expect(await queryByText('First option: Three')).not.toBeInTheConsole()
41+
})
42+
```
43+
44+
Check out
45+
[CLI Testing Library's documentation](https://github.com/crutchcorn/cli-testing-library)
46+
for a full list of its API.
47+
48+
- [CLI Testing Library on GitHub](https://github.com/crutchcorn/cli-testing-library)

sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ module.exports = {
202202
'ecosystem-query-extensions',
203203
'ecosystem-rtl-simple-queries',
204204
'ecosystem-testing-library-selector',
205+
'ecosystem-cli-testing-library',
205206
],
206207
},
207208
],

0 commit comments

Comments
 (0)