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

coffee

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coffee

Test command line on nodejs

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
increased by18.48%
Maintainers
1
Weekly downloads
 
Created
Source

Coffee

Test command line on nodejs


NPM version Build Status Build Status NPM downloads

Install

$ npm install coffee -g

Usage

Coffee is useful to test command line in Mocha or other test frammework.

describe('cat', function() {
  it('should concat input', function(done) {
    var coffee = require('coffee');
    coffee.spawn('cat')
    .write('1')
    .write('2')
    .expect('stdout', '12')
    .expect('code', 0)
    .end(done);
  })
})

You can also use fork for spawning Node processes.

coffee.fork('/path/to/file.js', ['args '])
.expect('stdout', '12\n')
.expect('stderr', '34\n')
.expect('code', 0)
.end(done);

In file.js

console.log(12);
console.log(34);

API

coffee.spawn

Run command using child_process.spawn, then return Coffee instance.

Arguments see child_process.spawn

coffee.fork

Run command using child_process.fork, then return Coffee instance.

Arguments see child_process.fork

Coffee

Assertion object

coffee.expect(type, expected)

Assert type with expected value, expected value can be string, regular expression, and array.

coffee.spawn('echo', ['abcdefg'])
.expect('stdout', 'abcdefg')
.expect('stdout', /^abc/)
.expect('stdout', ['abcdefg', /abc/])
.end(done);

Accept type: stdout, stderr, code, error

coffee.write(data)

Write data to stdin, see example above.

coffee.end(callback)

Callback will be called after completing the assertion, the first argument is Error if throw exception.

coffee.debug()

Write data to process.stdout and process.stderr for debug

LISENCE

Copyright (c) 2015 popomore. Licensed under the MIT license.

Keywords

FAQs

Package last updated on 23 May 2015

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