Avoiding multiple asserts
This file contains 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