Add custom message to Jest expects
Overall
score
99%
{
"context": "This evaluation assesses the engineer's proficiency in using jest-expect-message with Jest's asymmetric matchers to create flexible, pattern-based test assertions with descriptive custom error messages.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Custom messages usage",
"description": "Tests use the jest-expect-message syntax by providing custom error messages as the second parameter to expect() calls (e.g., expect(value, 'message').toBe(expected)). At least 3 tests should include meaningful custom messages.",
"max_score": 25
},
{
"name": "expect.any() usage",
"description": "Tests use expect.any() to match types without hardcoding exact values (e.g., expect.any(Number), expect.any(String)). Should be used to validate the timestamp and other dynamic fields.",
"max_score": 20
},
{
"name": "expect.objectContaining() usage",
"description": "Tests use expect.objectContaining() to perform partial object matching, validating that objects contain expected properties without requiring exact matches (e.g., expect.objectContaining({ propertyName: expectedValue })).",
"max_score": 20
},
{
"name": "expect.arrayContaining() usage",
"description": "Tests use expect.arrayContaining() to validate array contents with flexible matching, checking that arrays contain elements matching expected patterns rather than exact values.",
"max_score": 15
},
{
"name": "Combined asymmetric matchers",
"description": "Tests combine multiple asymmetric matchers in nested structures (e.g., expect.objectContaining({ field: expect.any(Type) }) or expect.arrayContaining([expect.objectContaining({ ... })])). At least one test should demonstrate nested matcher usage.",
"max_score": 15
},
{
"name": "Message quality",
"description": "Custom error messages are descriptive and clearly explain what is being validated. Messages should describe the business logic or pattern being tested, not just repeat the assertion (e.g., 'API response should match expected structure with dynamic timestamp' rather than 'response equals expected').",
"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