https://github.com/mhio/node-mhio-test-cli
Cli command and code test helpers
https://github.com/mhio/node-mhio-test-cli
Last synced: 2 months ago
JSON representation
Cli command and code test helpers
- Host: GitHub
- URL: https://github.com/mhio/node-mhio-test-cli
- Owner: mhio
- License: mit
- Created: 2017-03-11T01:09:54.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-02-11T01:05:59.000Z (over 3 years ago)
- Last Synced: 2025-03-18T04:58:08.489Z (2 months ago)
- Language: JavaScript
- Size: 131 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [mhio - test cli commands](https://github.com/mhio/mhio-test-cli)
## @mhio/test-cli
Helper classes for testing cli commands and cli code.
Stores the stdout, stderr and return of the command for subsequent testing.
## Install
yarn add mhio-test-cli --devnpm install mhio-test-cli --save-dev
## Usage
### Cli
```javascript
const { Cli } = require('@mhio/test-cli')
Cli.run(['echo', 'test']).then(results => {
console.log(results.stdout)
console.log(results.stdout)
console.log(results.exit_code)
})```
### Cli Code
```javascript
const { CliCode } = require('@mhio/test-cli')
const fn = ()=> {
console.log('testout')
console.error('testerr')
process.exit(1)
}CliCode.run(fn).then(results => {
console.log(results.stdout)
console.log(results.stdout)
console.log(results.return) // The data the function returns
console.log(results.exit) // Did the code try to exit
console.log(results.exit_code) // What was the exit code
})```
## About
mhio-test-cli is released under the MIT license.
Copyright 2019 mhio
https://github.com/mhio/mhio-test-cli