System test runner based on tape

npm install scenario
4 downloads in the last week
9 downloads in the last month


Scenario is a vertical test composer based on tape. Generically speaking, it allows you to compose a set of independent test steps into multiple test scenarios. It is primarily aimed at being a system test runner for tests based on the Gherkin BDD langauge and a lightweight alternative to Cucumber.js. A feature of a system is tested by constructing test scenarios, each of which is associated with a collection of named test steps. Each step is defined and implemented independently, using a context variable to pass data between steps, allowing for simple DRY code. Collections of related scenarios define test cases for a feature.


// index.js

var test = require("tape")
var scenario = require("scenario")()

var feature = require("example.feature.js")

// Register the scenarios with the test builder

// Build the tape tests
var tests =

// Run the tests
// example.feature.js

function feature(scenario) {
    scenario("As a user I can do something", [
        "I am a user",
        "I want to do something",
        "I do the thing",
        "something happens"

    scenario.define(/^I am a user$/, function (context, assert) {
        context.user = "Matt"

    scenario.define(/^I want to do things$/, function (context, assert) {
        context.thing = 1
        context.doThing = function () {
            context.thing += 1

    scenario.define(/^I do the thing$/, function (context, assert) {

    scenario.define(/^something happens$/, function (context, assert) {
        assert.equal(context.thing, 2, "The thing happened")
# example.feature

Feature: Example Feature

    In order to be productive,
    as a user
    I want to do things

    Scenario: A user does something

        Given I am a user
        And I want to do something
        When I do the thing
        Then something happens


Gherkin feature scaffolding

Gherkin test runner


npm install scenario

or for the gherkin tools

npm install scenario -g


  • Matt-Esch

MIT Licenced

npm loves you