Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dex4er/js-tap-given
Given-When-Then BDD for TAP
https://github.com/dex4er/js-tap-given
Last synced: 7 days ago
JSON representation
Given-When-Then BDD for TAP
- Host: GitHub
- URL: https://github.com/dex4er/js-tap-given
- Owner: dex4er
- License: mit
- Created: 2017-02-18T19:09:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-29T15:05:47.000Z (about 7 years ago)
- Last Synced: 2024-04-29T10:07:30.415Z (5 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/tap-given
- Size: 45.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## tap-given
[![Build Status](https://secure.travis-ci.org/dex4er/js-tap-given.svg)](http://travis-ci.org/dex4er/js-tap-given) [![Coverage Status](https://coveralls.io/repos/github/dex4er/js-tap-given/badge.svg)](https://coveralls.io/github/dex4er/js-tap-given) [![npm](https://img.shields.io/npm/v/tap-given.svg)](https://www.npmjs.com/package/tap-given)
This module provides [tap](https://www.npmjs.com/package/tap) API with
[Mocha-like DLS](http://www.node-tap.org/mochalike/) as Given-When-Then style
for BDD tests.### Requirements
This module requires Node >= 4.
### Installation
```shell
npm install tap-given
```### Usage
__Feature__: TDD in Given-When-Then style
__Scenario__: Basic scenario
__Given__ `examples/test.js` file:
```js
const t = require('tap')
require('tap-given')(t)
require('chai').should()Feature('TDD in Given-When-Then style for TAP', () => {
Scenario('Basic scenario', () => {
let a, b, cGiven('first value', () => {
a = 2
})And('second value', () => {
b = 21
})When('I do multiplication operation', () => {
c = a * b
})Then('the result is correct', () => {
c.should.equal(42)
})
})
})
```__When__ I run `tap` command:
```sh
$ tap -R spec examples/test.js
```__Then__ following output is produced:
```
examples/test.js
Feature: TDD in Given-When-Then style for TAP
Scenario: Basic scenario
✓ Given first value
✓ And second value
✓ When I do multiplication operation
✓ Then the result is correct4 passing (233.031ms)
```### Functions
`Feature` function is an alias to `describe` function and might be optional.
`Scenario` function is an alias to `context` function. It usually provides a
context for its steps then real `function () {}` might be used instead arrow
`() => {}` notation.`Given`, `When`, `Then` and `And` functions are aliases to `it` function.
`Before`, `beforeEach`, `After` and `afterEach` functions are also provided
and are optional.For `Before` and `After` functions the first argument is optional.
All functions except `BeforeEach` and `AfterEach` add some prefix to the
description of the step.### Typescript
Use following syntax instead `require`:
```ts
import * as tap from 'tap'
import { tapGiven } from 'tap-given'
tapGiven(tap)
```### Linter
Install `eslint-plugin-tap-given` module and use in `package.json`:
```js
{
"standard": {
"plugins": [ "tap-given" ],
"env": [ "tap-given/tap-given" ]
}
}
```or:
```js
{
"eslintConfig": {
"plugins": [ "tap-given" ],
"env": {
"tap-given/tap-given": true
}
}
}
```Without plugin:
```js
{
"standard": {
"globals": [
"After",
"AfterEach",
"And",
"Before",
"BeforeEach",
"Feature",
"Given",
"Scenario",
"Then",
"When"
]
}
}
```or:
```js
/* global Feature, Scenario, Given, When, Then, And, Before, BeforeEach, After, AfterEach */
```### License
Copyright (c) 2017 Piotr Roszatycki
[MIT](https://opensource.org/licenses/MIT)