Skip to content

Instantly share code, notes, and snippets.

@jhartikainen
Last active Nov 25, 2016
Embed
What would you like to do?
Avoiding multiple asserts
//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