Skip to content

gabriel-deliu/given-when-then-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

given-when-then-js

basic given when then test helper [Javascript]

install

npm i given-when-then-js

npm package link

how to use

var given = require('given-when-then-js');
var expect = require('chai').expect;

//alternativley with ES6 via transpilers
//import given from 'given-when-then-js';
//import { expect } from 'chai';

it('runs in the most basic form', () => {
	given(1)
		.when(value => 2)
		.then(value => value == 2);
});

it('should do a basic flow', () => {
	var givenValue = 1;
	var whenValue = 2;

	given(givenValue, "given a basic value")
		.when(value => {
			expect(value).to.equal(givenValue);
			/*perform action and return result*/
			return whenValue;
		}, "given value should be passed to when")
		.then(value => {
			/*check if the result matches the expected result*/
			expect(value).to.equal(whenValue);
		}, "when value should be passed to then");
});

see also

Java 8 version: given-when-then

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published