In the latest ember-cli, in the unit tests the test
function expect as last parameter a function which would have the assert
object as first parameter.
I was wondering how can I extend this object to add my own custom assertion helpers?
For example I want to add a controlDisabled
helper that would return true if the control is disabled, and false otherwise. So somewhere (but not in each test files) I want to extend that assert
object given as paramter like so:
assert.controlDisabled = function(selector, message) {
return this.ok(findWithAssert(selector).attr('disabled'), message);
};
Where should I define this?
The assert
object is a singleton instance which you can gain access with QUnit.assert
. So the following should work
import QUnit from 'qunit';
QUnit.assert.controlDisabled = function(selector, message) {
return this.ok(findWithAssert(selector).attr('disabled'), message);
};