cuke-tap
Gherkin tap producing test harness
Last updated 4 years ago by ahdinosaur .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cuke-tap 
SYNC missed versions from official npm registry.

cuke-tap

NPM version build status Test coverage Downloads js-standard-style

Cucumber BDD tests, TAP style. cuke-tap provides a minimal interface to perform cucumber-style integration tests.

Installation

$ npm install cuke-tap

Usage

test/index.js

const cuke = require('cuke-tap')
const path = require('path')

const features = path.join(__dirname, 'example.feature')
const steps = require('./steps')

cuke({
  steps: steps,
  features: features
})

test/example.feature

Feature: Example feature
  As a user of cucumber.js
  I want to have documentation on cucumber
  So that I can concentrate on building awesome applications

  Scenario: Reading documentation
    Given I am on the cuke-tap repo page
    When I go to the README file
    Then I should see "Usage" as the page title

test/steps.js

const test = require('cuke-tap')
const jsdom = require('jsdom')

module.exports = [
  [/^I am on the cuke-tap repo page$/, (t, world, params) => {
    t.plan(1)
    jsdom.env('http://localhost:1337', (err, window) => {
      t.error(err)
      world.window = window
      window.location.pathname = '/foo'
      t.pass('done')
    }
  }],
  [/^I go to the README file$/, (t, world, params) => {
    t.plan(2)
    const window = world.window
    const document = window.document
    const el = document.querySelectorAll('.foo.bar')
    t.ok(el)
    el.click()
    t.equal(window.location.pathname, '/baz')
  }],
  [/^I should see "(.*)" as the page title$/, (t, world, params) => {
    t.plan(1)
    const document = world.window.document
    t.equal(document.title, 'baz, the best beep')
  }]
]


API

cuke(options, cb)

Run cucumber tests.

  • options.features - either a glob string or array of file paths of .feature files in Gherkin syntax
  • options.steps - an array of steps
  • cb - an error-first callback after tests are finished

Each defined step is an array of [regex, fn(t, world, params)] where:

  • regex: the regex that is matched against the gherkin definitions
  • t: instance of tape's t
  • world: a world object that is shared between tests
  • params: the regex match groups

Todo

  • [x] get base version working
  • [x] add support for full syntax range (requires parser rewrite)
  • [ ] add support for table tests

See Also

License

MIT

Current Tags

  • 2.1.0                                ...           latest (4 years ago)

7 Versions

  • 2.1.0                                ...           4 years ago
  • 2.0.2                                ...           4 years ago
  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (4)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |