ember-cli-custom-assertions-collection
Turns out it's impossible to effectively use Chai in QUnit. Chai throws exceptions on failed Chai assertions, which are tracked by QUnit, though with a poor message. But Chai is unable to report successful assertions to QUnit. If you compose a QUnit test entirely from Chai assertions, QUnit will fail due to no assertions.
This is really unfortunate because Chai has a decent assertions library, and QUnit's library is very basic and often not enough.
This Ember addon aims to provide missing assertions and many more.
Assertions themselves are properly unit-tested.
Work in progress
This addon is WIP and is being populated with assertions as they are needed.
Feel free to join. Find yourself doing clumsy stuff in tests? PR a custom assertion!
Dependencies
This addon depends on the following addons:
And plain npm packages:
If you find it not working due to something of the above missing, try installing that into your app. And file an issue here!
Usage
- Install ember-cli-custom-assertions and wrap your head around it.
- Install this addon:
ember cli install ember-cli-custom-assertions-collection
. - If a test needs a custom assertion, configure it to use
ember-cli-custom-assertions
. - Use any assertion from this collection, e. g.
assert.isFalse(foo, 'foo should be false')
.
The assertions
isFalse( obj[, message] )
Checks if obj
is exactly false
.
arraysSameMembers( arr1, arr2, [, message] )
Checks if both arrays have identical content, in any order. Members are compared via ===
.
arraysSameMembersOrdered( arr1, arr2, [, message] )
Checks if both arrays identical content, in identical order. Members are compared via ===
.
Plans
If this thing catches up, we could document it with YUIDOC.
All suggestion are welcome in issues and in Ember Slack community.
Oh, and don't forget to star the addon on Github! :beers"
Credit
Created in Firecracker.