https://github.com/corentinth/comest
Small and lightweight cli-testing framework.
https://github.com/corentinth/comest
Last synced: 9 months ago
JSON representation
Small and lightweight cli-testing framework.
- Host: GitHub
- URL: https://github.com/corentinth/comest
- Owner: CorentinTh
- License: mit
- Created: 2020-06-11T05:49:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-07-21T03:25:46.000Z (over 3 years ago)
- Last Synced: 2025-03-13T15:15:59.392Z (10 months ago)
- Language: TypeScript
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# comest
Small and lightweight cli-testing framework.
## Installation
You can run `comest` without installing it by using `npx`:
```shell
npx comest
```
Or you can install it by running:
```shell
npm i -g comest
# use it by typing
comest
```
## Usage
Create test files matching `*.test.yml` like `myFile.test.yml` in a folder `test`.
### Basic example
This test run the command `echo foo` and checks 'yo' has been printed on stdout.
```yaml
name: Simple echo test
command: echo foo
expect:
status: 0
stdout: foo
```
This test run the command `echo foo && exit 42` and checks 'yo' has been printed on stdout and return value is 42.
```yaml
name: Simple echo test
command: echo foo && exit 42
expect:
status: 42
stdout: foo
```
### With files
This test will create a tmp file containing "Lorem ipsum" and will replace `{file1}` with the absolute path of the tmp file ni the command, and execute it. It will then compare the result of the command with the things in **expect**.
```yaml
name: Print file content
command: cat {file1}
assets:
- type: file
name: file1
content: Lorem ipsum
expect:
status: 0
stdout: Lorem ipsum
```
This test will fail because the expectation is different
```yaml
name: Print file content
command: cat {file1}
assets:
- type: file
name: file1
content: Lorem ipsum
expect:
status: 0
stdout: dolor sit amet
```
### Multiline
According to the YAML [specification](https://yaml-multiline.info/), I suggest using `|-` for multiline (as it keep line break but not the last one).
```yaml
name: Print my C file content
command: cat {file1}
assets:
- type: file
name: file1
content: |-
int main () {
return 56;
}
expect:
status: 0
stdout: |-
int main () {
return 56;
}
```
### Multi steps
```yaml
name: Steps demo
assets:
- type: file
name: file1
steps:
- command: echo "foo" > {file1}
expect:
status: 0
- command: echo "bar" >> {file1}
- command: cat {file1}
expect:
status: 0
stdout: |-
foo
bar
```