Created
June 16, 2025 10:58
-
-
Save isocroft/820ae4e6cd0f78ed19581b6e2323f43b to your computer and use it in GitHub Desktop.
This is a file that holds a good amount of custom matchers for Jest
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
expect.extend({ | |
toBeArrayContainingObject(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