# inquirer-test

> functional testing for inquirer.js

Latest version **2.0.1** (published 2017-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install inquirer-test
pnpm add inquirer-test
yarn add inquirer-test
bun add inquirer-test
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2017-12-10 |
| First published | 2016-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | ewnd9 |
| Maintainers | ewnd9 |
| Keywords | inquirer, test, child_process |

## Links

- npm: https://www.npmjs.com/package/inquirer-test
- Repository: https://github.com/ewnd9/inquirer-test
- Homepage: https://github.com/ewnd9/inquirer-test#readme
- Issues: https://github.com/ewnd9/inquirer-test/issues
- npm.io page: https://npm.io/package/inquirer-test

## Dependencies (1)

- [concat-stream](https://npm.io/package/concat-stream.md) ^1.5.1

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2017-12-10
- 1.0.5 — 2016-03-15
- 1.0.4 — 2016-03-15
- 1.0.3 — 2016-02-05
- 1.0.2 — 2016-02-05
- 1.0.1 — 2016-02-03
- 1.0.0 — 2016-02-03
- 2.0.0 — 2016-02-03

## README

# inquirer-test

[![Build Status](https://travis-ci.org/ewnd9/inquirer-test.svg?branch=master)](https://travis-ci.org/ewnd9/inquirer-test)

Functional testing for [inquirer.js](http://npmjs.com/package/inquirer)

> Could be use to test output of commands with regexs or side effects from running a script.
>
> E.g. with project generators you provide a combinations of control keys and text inputs and ensure
> that files are generated with `fs` or other modules.

## Install

```
$ npm install inquirer-test --save-dev
```

## Usage

```js
// cli.js

const inquirer = require('inquirer');
const outputs = ['TEST-1', 'TEST-2', 'TEST-3'];

inquirer.prompt({
  type: 'list',
  name: 'q',
  message: 'hi',
  choices: [ '1', '2', '3' ]
}).then(function(answers) {
  console.log(outputs[+answers.q - 1]);
});
```

```js
// test.js

import test from 'ava';
import run, { UP, DOWN, ENTER } from 'inquirer-test';

const cliPath = __dirname + '/cli.js';

test('press enter', async t => {
  const result = await run([cliPath], [ENTER]);
  t.regex(result, new RegExp('TEST-1', 'g'));
});

test('press down, press enter', async t => {
  const result = await run([cliPath], [DOWN, ENTER]);
  t.regex(result, new RegExp('TEST-2', 'g'));
});

test('press up, press enter', async t => {
  const result = await run([cliPath], [UP, ENTER]);
  t.regex(result, new RegExp('TEST-3', 'g'));
});

test('press press up, press down, press enter', async t => {
  const result = await run([cliPath], [UP, DOWN, ENTER]);
  t.regex(result, new RegExp('TEST-1', 'g'));
});

test('run with data input', async t => {
  const result = await run([cliPath], ['input-1', ENTER, 'input-2', ENTER]);
  t.regex(result, new RegExp("username: 'input-1', password: 'input-2'", 'g'));
});
```

## Changelog

- `v2.0.0`
  - change cliPath to `child_process` arguments array
  - update to `inquirer@4`

## Related

- [inquirer](https://github.com/sboudrias/Inquirer.js)
- [inquirer-bluebird](https://github.com/ewnd9/inquirer-bluebird)
- [inquirer-question](https://github.com/ewnd9/inquirer-question)
- [inquirer-credentials](https://github.com/ewnd9/inquirer-credentials)
- [inquirer-menu](https://github.com/ewnd9/inquirer-menu)

## License

MIT © [ewnd9](http://ewnd9.com)

---
_Source: https://npm.io/package/inquirer-test · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
