Socket
Socket
Sign inDemoInstall

tests

Package Overview
Dependencies
10
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tests

Console test runner - writes to stdin, reads stdout


Version published
Weekly downloads
4.7K
increased by85.57%
Maintainers
1
Install size
1.16 MB
Created
Weekly downloads
 

Readme

Source

tests.js

Console Test Runner: writes to stdin, reads stdout.

tests.js is useful for test-driven development of command-line utilities. Works on Mac OS X, Windows and Linux so you can write cross-platform tests. Tests do not depend on the implementation language of the program.

Usage

You will need Node.js and NPM. Install using the following command.

$ npm install -g tests

Then create some .test files and execute the following command in the folder with tests.

$ tests

Test files should have the following structure.

  • first line—command to execute (can be relative path, can contain pipeline of several commands),

  • then <<< and input to send to the program (can be multiple lines),

  • then >>> and expected output.

Example:

wc
<<<
one two three
>>>
       1       3      14

This test executes wc command, sends string one two three to its stdin and checks the output of the program.

When the test is run you should see something like

✓  /path/to/tests/wc.test: 9ms

✔  1 test complete (9ms)

To compare program’s output with expected output not as literal strings but as JSON objects write >>>JSON in the test file instead of >>>.

For more examples see https://github.com/sheremetyev/texts.js/tree/master/test.

Acknowledgements

The idea was borrowed from John MacFarlane’s tests format in Pandoc2.

Keywords

FAQs

Last updated on 21 Jan 2013

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc