Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

comest

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comest

Simple command tester

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

comest

Small and lightweight cli-testing framework.

Installation

You can run comest without installing it by using npx:

npx comest

Or you can install it by running:

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.

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.

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.

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

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, I suggest using |- for multiline (as it keep line break but not the last one).

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

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

FAQs

Package last updated on 27 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc