Build Status Coverage Status Code Climate Known Vulnerabilities Styled with prettier

License NPM package Quality

Description

JsGiven aims to bring BDD (Behavior-Driven Development) to plain (or typed) JavaScript.

It is a developer-friendly and pragmatic BDD tool for JavaScript.

Developers write scenarios in plain JavaScript using a fluent, domain-specific API, JsGiven generates reports that are readable by domain experts.

It’s a JavaScript port of JGiven (written in Java). JsGiven keeps the JGiven philosophy, concepts and uses its html5 reporting tool.

You can have a look at JSGiven’s own report

scenarios('recipes', RecipesStage, ({given, when, then}) => ({
    a_pancake_can_be_fried_out_of_an_egg_milk_and_flour: scenario({}, () => {
        given().an_egg().
            and().some_milk().
            and().the_ingredient('flour')

        when().the_cook_mangles_everything_to_a_dough().
            and().the_cook_fries_the_dough_in_a_pan()

        then().the_resulting_meal_is_a_pan_cake()
    })
}))

It can be used with any javascript test runner (like Jest, Ava, Mocha, Jasmine, or Protractor).

It can be used with your favorite assertion library (like ChaiJS, Jasmine), or your framework’s assertion library.

It aims to provide the most comfortable developer experience with optional ES6 syntax, and optional Flow or TypeScript typings.

Some features are missing, but we are already using it daily at https://www.fluo.com

Don’t hesitate to give any feedback and to open a GitHub issue https://github.com/jsGiven/jsGiven/issues

Getting started

You can start using JsGiven with the user guide

Changelog

  • v0.1.4 (25th June 2017): Add parameter formatting feature.

  • v0.1.3 (21st June 2017): Add hidden step feature.

  • v0.1.2 (13th June 2017): Upgrade dependencies (most notable one being the jGiven report)

  • v0.1.1 (5th June 2017): Add TypeScript support

  • v0.1.0 (4th June 2017): Initial stable release

    • Includes asynchronous testing support, parametrized steps & scenarios.

    • Includes a breaking API change in order to implement tags & extended descriptions on scenarios.

  • v0.0.* : Early releases

    • v0.0.20 Fix state-sharing issue when running asynchronous test

    • v0.0.19 Implement asynchronous testing support

    • v0.0.18 Download jgiven with https to fix vulnerability discovered by snyk : https://snyk.io/vuln/npm:js-given

    • v0.0.17 Remove humanization of group names as it prevents grouping in JGiven’s report

    • v0.0.15 Fix report generation issue introduced in v0.0.14

    • v0.0.14 Fix report generation issue when there is no report

    • v0.0.13 Do not include babel-polyfill in lib

    • v0.0.12 Add flow type definition

    • v0.0.11 Add parametrized tests support

    • v0.0.10 Add jest+es2015 example