Add custom message to Jest expects
Overall
score
99%
{
"context": "This criteria evaluates the engineer's proficiency in using Jest's expect.extend API to create custom matchers, and their understanding of how jest-expect-message maintains compatibility with these custom matchers. The focus is on proper implementation of custom matcher functions with correct return values and message functions.",
"type": "weighted_checklist",
"checklist": [
{
"name": "expect.extend usage",
"description": "Uses expect.extend() to register all four custom matchers (toBeValidPrice, toBeInStock, toHaveCategory, toHaveAllTags)",
"max_score": 25
},
{
"name": "Matcher return structure",
"description": "Each custom matcher returns an object with 'pass' (boolean) and 'message' (function returning string) properties as required by Jest's expect.extend API",
"max_score": 20
},
{
"name": "toBeValidPrice implementation",
"description": "Implements toBeValidPrice matcher that correctly validates positive numbers with at most 2 decimal places, checking both the numeric value and decimal precision",
"max_score": 10
},
{
"name": "toBeInStock implementation",
"description": "Implements toBeInStock matcher that checks if product.stock > 0",
"max_score": 10
},
{
"name": "toHaveCategory implementation",
"description": "Implements toHaveCategory matcher that accepts an expected category parameter and compares it with product.category",
"max_score": 10
},
{
"name": "toHaveAllTags implementation",
"description": "Implements toHaveAllTags matcher that accepts an array of expected tags and verifies all are present in product.tags",
"max_score": 10
},
{
"name": "Negation support",
"description": "All matchers provide appropriate error messages for both positive and negative cases (with and without .not), using conditional logic based on the 'pass' value",
"max_score": 10
},
{
"name": "Jest-expect-message compatibility",
"description": "The custom matchers work correctly when used with jest-expect-message's custom message syntax: expect(value, 'custom message').toCustomMatcher()",
"max_score": 5
}
]
}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