Last active
November 25, 2016 08:43
-
-
Save jhartikainen/b1cf5af0f7a3fee384594b9bb1e325c5 to your computer and use it in GitHub Desktop.
Avoiding multiple asserts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//easy way to check if object has the expected "shape": | |
it('tests something', function() { | |
var expectedObject = { | |
some: 'prop', | |
values: 'here' | |
}; | |
var result = doStuff(); | |
assert.deepEqual(result, expectedObject); | |
}); | |
//but if we want to check the object has some properties, | |
//where it might have more props than those, we can use... | |
assert(sinon.match(result).test(expectedObject)) | |
//or alternatively, something like | |
//https://github.com/michelsalib/chai-shallow-deep-equal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment