cucumber-assert
An assertion library for cucumber.js. It allows assertions in cucumber.js without extra-long stacktraces when an assertion fails.
Installation
npm install cucumber-assert
Note
As of Version 2.0, cucumber-assert uses Promises. If you need the old version without Promises, install Version 1.0.4:
npm install cucumber-assert@1.0.4
Example usage
var assert = ; module { this; }
Multiple operations
If you need multiple assertions in one step, you can simply wait to resolve all the Promises. Since Promise.all()
will resolve with an array of the results, Promise.all(...).then(callback)
would result in a broken test, since calling the callback with a parameter tells cucumber, that something went wrong. You can either use Promise.all(...).then(() => callback())
or the provided .all()
Method:
var assert = ; module { this; }
instead of
Promiseallpromises;
Available assertions
Generally cucumber-assert wraps the assertions available by default in node. For reference see http://nodejs.org/api/assert.html
The parameter "callback" is the callback provided by cucumber.js in step definitions and has to be passed always alongside the actual values and expectations.
equal(actual, expected, callback, [message])
assert;
notEqual(actual, expected, [message])
assert;
deepEqual(actual, expected, [message])
assert;
notDeepEqual(actual, expected, [message])
assert;
strictEqual(actual, expected, [message])
assert;
notStrictEqual(actual, expected, [message])
assert;
throws(block, [error], [message])
assert;
doesNotThrow(block, [message])
assert;
ifError(value, [message])
assert;