2.1.0 • Published 8 years ago

cuke-tap v2.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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

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

See Also

License

MIT

2.1.0

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago