Parameterised tests for Jest that enable running the same test multiple times with different data sets using arrays or tagged template literals
85
{
"context": "This evaluation assesses how effectively the engineer uses Jest's mockImplementation and mockImplementationOnce functions to create dynamic mock behavior for testing different payment scenarios. The focus is entirely on proper usage of these specific Jest mocking APIs.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Uses jest.fn()",
"description": "Creates mock functions using jest.fn() for the provider functions that need to be mocked",
"max_score": 15
},
{
"name": "Uses mockImplementation",
"description": "Employs mockImplementation() to define custom behavior for mock functions, allowing providers to return specific payment results",
"max_score": 25
},
{
"name": "Uses mockImplementationOnce",
"description": "Uses mockImplementationOnce() to create different behaviors for sequential calls to the same mock function, enabling tests for varying payment results",
"max_score": 25
},
{
"name": "Mock return values",
"description": "Configures mocks to return properly structured payment result objects with status and transactionId fields",
"max_score": 15
},
{
"name": "Mock error scenarios",
"description": "Uses mockImplementation or mockImplementationOnce to throw errors, testing error handling in the payment processor",
"max_score": 10
},
{
"name": "Verifies mock calls",
"description": "Uses Jest's mock verification matchers (toHaveBeenCalled, toHaveBeenCalledWith) to verify mocks were called correctly",
"max_score": 10
}
]
}Install with Tessl CLI
npx tessl i tessl/npm-jest-eachdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10