Skip to content

Instantly share code, notes, and snippets.

@pluto-atom-4
Last active November 13, 2019 00:22
Show Gist options
  • Save pluto-atom-4/08ef55e2aaab2d2001b48282c08dbf6e to your computer and use it in GitHub Desktop.
Save pluto-atom-4/08ef55e2aaab2d2001b48282c08dbf6e to your computer and use it in GitHub Desktop.
jest-notes
expect.extend({
toContainObject(received, argument) {
const pass = this.equals(received,
expect.arrayContaining([
expect.objectContaining(argument)
])
)
if (pass) {
return {
message: () => (`expected ${this.utils.printReceived(received)} not to contain object ${this.utils.printExpected(argument)}`),
pass: true
}
} else {
return {
message: () => (`expected ${this.utils.printReceived(received)} to contain object ${this.utils.printExpected(argument)}`),
pass: false
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment