JavaScript Runner for Gauge.
-
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`
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
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/
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");
});
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 beginsbeforeSpec (fn, [opts])
- Executed before each specificationbeforeScenario (fn, [opts])
- Executed before each scenariobeforeStep (fn, [opts])
- Execute before each step
"After" hooks:
afterSuite (fn, [opts])
- Executed after the test suite beginsafterSpec (fn, [opts])
- Executed after each specificationafterScenario (fn, [opts])
- Executed after each scenarioafterStep (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 ofOR
).
Example of a tagged execution hook implementation:
beforeScenario (function () {
assert.equal(vowels[0], "a");
}, { tags: [ "single word" ]});
Setup:
- Preferably use EditorConfig with your text editor.
Install npm dependencies:
$ npm install
Run tests:
$ npm run check-style
$ npm run lint
$ npm test
$ npm run package
- Indent: 2 spaces
- Line ending: LF
Gauge-JS is released under GNU Public License version 3.0