1.3.0 • Published 4 years ago

mocha-like-gherkin v1.3.0

Weekly downloads
-
License
CC-BY-NC-SA-4.0
Repository
github
Last release
4 years ago

README

Functions to render describe() and it() like gherkin with mocha

install

npm install mocha-like-gherkin

usage

usage node esm

import { docstring, givenfunction} from 'mocha-like-gherkin';
console.log(docstring('hello mocha-like-gherkin\nhello esm', {indent: 6, sep: '"""'}));
// ```
//      """
//      hello mocha-like-gherkin
//      hello esm
//      """`)
// ```
console.log(givenfunction('helloEsm', [10, 'hello', {a:"b"}, ['c', 'd']]));
// ```
// Given helloEsm(10, "hello", {"a":"b"}, ["c","d"])
// ```

usage node cjs (or typescript)

import { docstring, givenfunction} from 'mocha-like-gherkin/commonjs'
console.log(docstring('hello mocha-like-gherkin\nhello cjs'));
// ```
//      """
//      hello mocha-like-gherkin
//      hello cjs
//      """`)
// ```
console.log(givenfunction('helloCjs', [10, 'hello', {a:"b"}, ['c', 'd']]));
// ```
// Given helloCjs(10, "hello", {"a":"b"}, ["c","d"])
// ```

feature

import { feature } from 'mocha-like-gherkin'
console.log(feature('feature title'));
// ```Feature: feature title```

scenario

import { scenario } from 'mocha-like-gherkin'
console.log(scenario('scenario title'));
// ```Scenario: scenario title```

step

import { step } from 'mocha-like-gherkin'
console.log(step('step title'));
// ```step title```

step + docstring

import { step } from 'mocha-like-gherkin'
console.log(step('step title', {docstring: "hello"}));
// ```step title
// """
// hello
// """
// ```

docstring

docstringify

import { docstringify } from 'mocha-like-gherkin'
console.log(docstringify({a: 10}));
// ```
//      """
//      {
//         "a": 10
//      }
//      """`)
// ```

step + docstringify

import { step } from 'mocha-like-gherkin'
console.log(step('step title', {docstringify: { "hello": "docstringify" }));
// ```step title
// """
// {
//     "hello": "docstringify"
// }
// """
// ```

doctringify && env INLINEDOCTRING=1

  • win shell : set INLINEDOCTRING=1
  • linux shell : export INLINEDOCTRING=1
import { docstring, docstringify} from 'mocha-like-gherkin'
console.log(process.env.INLINEDOCTRING) // must return **string** "1"

console.log(docstring("aaaaa\nbbbb"));
// return `` """aaaaa\nbbbb"""`)``

console.log(docstringify({a: 10}));
// return `` """{"a": 10}"""`)``

alternatives

1.3.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.2

4 years ago

1.0.0

4 years ago