Giter Site home page Giter Site logo

gauge-js's Introduction

Gauge-JS

JavaScript Runner for Gauge.

Build Status

Install

  • Download gauge-js-<version>.zip from the releases page.

  • Install plugin from downloaded file:

    $ gauge --install js --file <path-to-zip-file>/gauge-js-<version>.zip`

Install from source

Clone Gauge-JS plugin repo:

$ git clone [email protected]:getgauge-contrib/gauge-js.git --recursive

Install plugin:

$ cd gauge-js
$ npm install
$ npm run installPlugin

Usage

If you are new to Gauge, please consult the Gauge documentation to know about how Gauge works.

Initialize: To initialize a project with gauge-js, in an empty directory run:

gauge --init js

Run specs:

gauge specs/

Methods

Step implementation

gauge (<step-text>, fn)

Use the gauge() method to implement your steps. For example:

gauge("Vowels in English language are <vowels>.", function(vowelsGiven) {
  assert.equal(vowelsGiven, "aeiou");
});

Execution Hooks

gauge-js supports tagged execution hooks. These methods are available for each type of hook:

"Before" hooks:

  • beforeSuite (fn, [opts]) - Executed before the test suite begins
  • beforeSpec (fn, [opts]) - Executed before each specification
  • beforeScenario (fn, [opts]) - Executed before each scenario
  • beforeStep (fn, [opts])- Execute before each step

"After" hooks:

  • afterSuite (fn, [opts]) - Executed after the test suite begins
  • afterSpec (fn, [opts]) - Executed after each specification
  • afterScenario (fn, [opts]) - Executed after each scenario
  • afterStep (fn, [opts])- Execute after each step

Here's an example of a hook that is executed before each scenario:

beforeScenario (function () {
    assert.equal(vowels.join(""), "aeiou");
});

opts:

Each hook takes an optional 2nd argument as an object. It can contain the following properties:

  • tags: Default: []. An array of strings for the tags for which to execute the current callback. These are only useful at specification or scenario level. If not specified, the provided callback is executed on each occurrence of the hook.
  • operator: Valid values: "AND", "OR". Default: "AND". This controls whether the current callback is executed when all of the tags match (in case of "AND"), or if any of the tags match (in case of OR).

Example of a tagged execution hook implementation:

beforeScenario (function () {
  assert.equal(vowels[0], "a");
}, { tags: [ "single word" ]});

Develop

Setup:

Install npm dependencies:

$ npm install

Run tests:

$ npm run check-style
$ npm run lint
$ npm test

Create package

$ npm run package

Code Style

  • Indent: 2 spaces
  • Line ending: LF

License

GNU Public License version 3.0 Gauge-JS is released under GNU Public License version 3.0

gauge-js's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.