inquirerer 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -73,6 +73,7 @@ npm install inquirerer
|
|
|
73
73
|
- [Progress Bar](#progress-bar)
|
|
74
74
|
- [Streaming Text](#streaming-text)
|
|
75
75
|
- [Custom UI with UIEngine](#custom-ui-with-uiengine)
|
|
76
|
+
- [Testing](#testing)
|
|
76
77
|
- [Developing](#developing)
|
|
77
78
|
|
|
78
79
|
## Quick Start
|
|
@@ -1642,6 +1643,51 @@ await engine.run({
|
|
|
1642
1643
|
});
|
|
1643
1644
|
```
|
|
1644
1645
|
|
|
1646
|
+
## Testing
|
|
1647
|
+
|
|
1648
|
+
For testing CLI applications built with `inquirerer`, use the companion
|
|
1649
|
+
package [`@inquirerer/test`](https://www.npmjs.com/package/@inquirerer/test)
|
|
1650
|
+
(also in this repo). It provides everything you need to mock stdin/stdout,
|
|
1651
|
+
queue keypresses and readline responses, capture and snapshot output, and
|
|
1652
|
+
even drive the built executable as a subprocess for end-to-end tests —
|
|
1653
|
+
without you having to hand-roll any of that scaffolding.
|
|
1654
|
+
|
|
1655
|
+
```bash
|
|
1656
|
+
npm install --save-dev @inquirerer/test
|
|
1657
|
+
```
|
|
1658
|
+
|
|
1659
|
+
**In-process testing** (mock streams):
|
|
1660
|
+
|
|
1661
|
+
```typescript
|
|
1662
|
+
import { createTestEnvironment, KEY_SEQUENCES } from '@inquirerer/test';
|
|
1663
|
+
import { Inquirerer } from 'inquirerer';
|
|
1664
|
+
|
|
1665
|
+
const env = createTestEnvironment();
|
|
1666
|
+
env.sendKey(KEY_SEQUENCES.ENTER);
|
|
1667
|
+
|
|
1668
|
+
const prompter = new Inquirerer(env.options);
|
|
1669
|
+
const result = await prompter.prompt({}, [
|
|
1670
|
+
{ name: 'confirm', type: 'confirm', message: 'Continue?' }
|
|
1671
|
+
]);
|
|
1672
|
+
|
|
1673
|
+
expect(result.confirm).toBe(true);
|
|
1674
|
+
expect(env.getOutput()).toContain('Continue?');
|
|
1675
|
+
```
|
|
1676
|
+
|
|
1677
|
+
**Subprocess (E2E) testing** — drive the actual built CLI:
|
|
1678
|
+
|
|
1679
|
+
```typescript
|
|
1680
|
+
import { runCli } from '@inquirerer/test';
|
|
1681
|
+
|
|
1682
|
+
const { stdout, exitCode } = await runCli('node', [CLI_ENTRY, 'search', 'hello']);
|
|
1683
|
+
expect(exitCode).toBe(0);
|
|
1684
|
+
expect(stdout).toContain('1 result');
|
|
1685
|
+
```
|
|
1686
|
+
|
|
1687
|
+
See the [@inquirerer/test README](https://github.com/constructive-io/dev-utils/tree/main/packages/inquirerer-test#readme) for the full API, including `createTestFixture` (temp-dir + commands runner), key-sequence constants, and snapshot normalisers.
|
|
1688
|
+
|
|
1689
|
+
## Developing
|
|
1690
|
+
|
|
1645
1691
|
**Run the demos:**
|
|
1646
1692
|
|
|
1647
1693
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inquirerer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "TypeScript-first library for building beautiful CLI interfaces with interactive prompts",
|
|
6
6
|
"main": "index.js",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"makage": "0.1.10",
|
|
47
47
|
"string-width": "4.2.3"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "d0e1a1b963e849c3e65a83e1cd7a183d9b5928a0"
|
|
50
50
|
}
|