Add custom message to Jest expects
Overall
score
99%
Build a validation system for an e-commerce product catalog that uses custom Jest matchers to verify product data integrity.
You need to implement custom Jest matchers that validate product objects according to business rules. Product objects have the following structure:
{
name: string,
price: number,
category: string,
stock: number,
tags: string[]
}Implement the following custom matchers:
All matchers should work with .not negation and provide clear error messages when assertions fail.
Your implementation should pass the following test cases:
@generates
/**
* Sets up custom Jest matchers for product validation.
* Call this function to register all custom matchers with Jest.
*/
function setupMatchers() {
// Implementation here
}
module.exports = { setupMatchers };Provides custom message support for Jest assertions, including compatibility with custom matchers added via expect.extend.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-jest-expect-messagedocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10