CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/jest-testing

Jest testing patterns — test structure, mocking, async testing, snapshot

99

1.26x
Quality

99%

Does it follow best practices?

Impact

99%

1.26x

Average score across 6 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-5/

{
  "context": "The agent must write Jest tests for a rate-limiting module that uses setTimeout internally. Tests must control time progression deterministically rather than waiting for real timers, and must restore timer state cleanly between tests.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "useFakeTimers in beforeEach",
      "description": "Agent calls jest.useFakeTimers() inside beforeEach (not inside individual tests) so all tests in the describe block start with fake timers active.",
      "max_score": 14
    },
    {
      "name": "useRealTimers in afterEach",
      "description": "Agent calls jest.useRealTimers() inside afterEach to restore real timers after each test, preventing timer leakage into other test files.",
      "max_score": 14
    },
    {
      "name": "advanceTimersByTime usage",
      "description": "Agent uses jest.advanceTimersByTime() to advance fake time by a specific duration rather than relying on real delays or jest.runAllTimers().",
      "max_score": 14
    },
    {
      "name": "clearAllMocks in beforeEach",
      "description": "Agent calls jest.clearAllMocks() in beforeEach to reset mock call history between tests.",
      "max_score": 10
    },
    {
      "name": "toHaveBeenCalledTimes verification",
      "description": "Agent uses toHaveBeenCalledTimes to verify the exact number of times a callback was invoked after advancing the timer.",
      "max_score": 14
    },
    {
      "name": "boundary condition tests",
      "description": "Agent includes tests for boundary conditions: exactly at the call limit, one over the limit, and behavior after the time window resets.",
      "max_score": 10
    },
    {
      "name": "describe/it structure",
      "description": "Agent uses one top-level describe per module with nested describe blocks per method or behavior group.",
      "max_score": 8
    },
    {
      "name": "it() verb-first descriptions",
      "description": "All it() description strings begin with a verb (e.g., 'executes', 'queues', 'resets') and not 'should ...'.",
      "max_score": 8
    },
    {
      "name": "no .only calls",
      "description": "No test.only, it.only, or describe.only appears in the submitted test file.",
      "max_score": 4
    },
    {
      "name": "not mocking subject under test",
      "description": "Agent does not mock the rate-limiter module itself — only callbacks are mocked with jest.fn().",
      "max_score": 4
    }
  ]
}

evals

tile.json