Control a program (typically a shell) over standard I/O for testing it
Last updated a year ago by binaris .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install specshell 
SYNC missed versions from official npm registry.

Build status


Write JavaScript specs for shell commands


For use only within your tests:

npm install --save-dev specshell

More advanced usage may require:

npm install --save specshell


  • Use any test framework (or none)
  • Use JavaScript or TypeScript

Quick start: testing shell commands

Write shell tests using your preferred test framework. Use specshell to run shell commands.

const specshell = require('specshell');

Create a new shell.

const shell = new specshell.Shell();

Send it a command and examine the results. Another process is involved so you must await the results of running any shell command. (Your test framework should support this; most do, including Jest, Mocha and Ava).

const assert = require('assert').strict;

async function test() {
  const { out, err } = await shell.run('echo hello, shell');
  assert.equal(out.toString(), 'hello, shell');
  assert.equal(err.toString(), '');

Shell.run returns exitCode or signal for each command run. If the shell itself dies it throws specshell.ShellError.



constructor(shellPath, spawnOptions)

Constructs to use a shell found at shellPath (default '/bin/bash') passing spawnOptions. Currently these are the same as for child_process.spawn, but option stdio will be ignored if you pass it.


Runs script inside shell: passes every line to the shell and a newline at the end.

Current Tags

  • 0.1.0                                ...           latest (a year ago)
  • 0.0.1-rc.2                                ...           rc (a year ago)

7 Versions

  • 0.1.0                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
  • 0.0.1-rc.2                                ...           a year ago
  • 0.0.1-rc.1                                ...           a year ago
  • 0.0.1-rc.0                                ...           a year ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (9)
Dependents (0)

Copyright 2014 - 2017 © taobao.org |