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

shellshot

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shellshot

A command-line interface testing extension for jest

  • 0.2.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

shellshot

build status code coverage maintainability code size npm minified size gitter donate Built with Spacemacs

A command-line interface testing extension for jest.


What is shellshot?

The main purpose of shellshot is running end2end tests for command-line applications. By providing a speaking API, it is also suited for non-javascript applications and is actually meant to be used for all types of command-line applications.

Features

  • Run any given command and test for stdout, stderr, and the exit code of the application
  • By integrating into jest all of the well known testing API can be used with shellshot
  • Checking content of files and streams
  • Using snapshot testing of jest

Getting started

Install shellshot in your current directory

$ npm install shellshot

This will create a node_modules folder containing all dependencies for shellshot including jest. Make sure to add node_modules to your .gitignore. The package-lock.json file should also be added to your .gitignore.

Creating your first test

To run jest tests in your current folder you need to create a jest configuration:

$ touch jest.config.js

You can leave the config empty for now.

Now create a new file awesome.test.js with the following content:

const { setup } = require('shellshot');

setup();

it(
    'should run my first shellshot test',
    async () => {
        await expect.command('ls -l')
            .forStdout(expectation => expectation.toContain('jest.config.js'))
            .forExitCode(expectation => expectation.toBe(0));
    },
);

Now run lets run your first test:

$ ./node_modules/.bin/jest
 PASS  ./awesome.test.js
  ✓ should run my first shellshot test (12ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.863s
Ran all test suites.

Have a look at the examples folder for more examples.

FAQs

Package last updated on 20 Mar 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