Add custom message to Jest expects
Overall
score
99%
{
"context": "This criteria evaluates how effectively the engineer uses jest-expect-message to write tests with nested matcher chains (.resolves, .rejects, .not) for async validation scenarios. The focus is on proper usage of the package's recursive matcher wrapping capability to provide clear custom error messages for complex async assertions.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Setup jest-expect-message",
"description": "Properly configures jest-expect-message in test setup (e.g., setupFilesAfterEnv or direct import) to enable custom messages on expect assertions",
"max_score": 10
},
{
"name": "Custom messages usage",
"description": "Provides custom error messages as the second parameter to expect() calls throughout the test suite (e.g., expect(actual, 'descriptive message'))",
"max_score": 15
},
{
"name": ".resolves matcher chain",
"description": "Uses expect().resolves chaining correctly for async assertions that should resolve successfully, with custom messages (e.g., expect(promise, 'message').resolves.toHaveProperty())",
"max_score": 20
},
{
"name": ".rejects matcher chain",
"description": "Uses expect().rejects chaining correctly for async assertions that should reject with errors, with custom messages (e.g., expect(promise, 'message').rejects.toThrow())",
"max_score": 20
},
{
"name": ".not.resolves chain",
"description": "Uses expect().not.resolves (or .resolves.not) chaining correctly to assert that promises should not resolve to certain values, with custom messages demonstrating nested matcher wrapping",
"max_score": 20
},
{
"name": "Message clarity",
"description": "Custom messages are clear, descriptive, and provide meaningful context about what is being tested (not generic messages like 'test failed')",
"max_score": 15
}
]
}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