jest

jest is a cursor rule for Cursor from sanjeed5/awesome-cursor-rules-mdc. It costs 2,543 tokens per session, scanned A, original, CC0-1.0.

Guidelines for writing Jest tests in JavaScript and TypeScript projects. Jest is a tool that runs automated tests and reports whether code behaves as expected.

In plain words
What is it for?
Use them when configuring Jest, testing application code, managing mocks, and measuring which source files are covered by tests.
Why use it?
They encourage consistent test setup, reliable isolation between tests, and useful coverage reports, making failures easier to understand.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: positional $N argument.

Good fit Use them when configuring Jest, testing application code, managing mocks, and measuring which source files are covered by tests.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/sanjeed5/awesome-cursor-rules-mdc/jest
About the project

awesome-cursor-rules-mdc is a generator that creates Cursor MDC rule files from structured library information, using semantic search and language models to gather and organize guidance. Developers use it to produce reusable rules for libraries in Cursor, and the catalogue includes 200 of those rules.

sanjeed5/awesome-cursor-rules-mdc · 3,571 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/sanjeed5/awesome-cursor-rules-mdc

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for jest

README.md
[![agentmods](https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/jest.svg)](https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/jest)
Your own site
<a href="https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/jest"><img src="https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/jest.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,543 This file is loaded in full into every session.
When invoked 2,543 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.02543 $0.02543
Opus 5 $0.01272 $0.01272
Sonnet 5 $0.00509 $0.00509
Haiku 4.5 $0.00254 $0.00254

Measured 4d ago against content hash 38701ecda85f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

jest scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules-mdc/jest.mdc · 371 lines

How it starts

The opening of the file, as written. The whole thing — 371 lines — stays where its author put it; the contents beside it link to each section on GitHub.

jest Best Practices

This guide outlines our team's definitive Jest best practices. Adhere to these rules for consistent, reliable, and efficient testing.

1. Configuration (jest.config.ts)

Always use a jest.config.ts file for type safety and explicit configuration.

// jest.config.ts
import type { Config } from 'jest';
import { defaults } from 'jest-config';

const config: Config = {
  // Use ts-jest for TypeScript files
  preset: 'ts-jest',
  // Automatically clear mock calls and instances between tests
  clearMocks: true,
  // Reset mocks between tests to prevent state leakage
  resetMocks: true,
  // Detailed test output
  verbose: true,
  // Collect coverage from specific files, exclude common boilerplate
  collectCoverageFrom: [
    'src/**/*.{js,jsx,ts,tsx}',
    '!src/**/*.d.ts',
    '!src/index.tsx', // Exclude entry points
    '!src/reportWebVitals.ts',
  ],
  // Ignore coverage for specific paths
  coveragePathIgnorePatterns: [
    '/node_modules/',
    'src/setupTests.ts',
  ],
  // Setup file for global test environment configurations (e.g., @testing-library/jest-dom)
  setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
  // Map module paths for aliases or specific packages
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1', // Example: for absolute imports
  },
  // Test environment for browser-like DOM APIs
  testEnvironment: 'jsdom',
  // Match test files ending with .test.ts(x) or .spec.ts(x)
  testMatch: [...defaults.testMatch, '**/?(*.)+(spec|test).[tj]s?(x)'],
};

export default config;

2. Test Organization

Colocate test files with the code they test. This improves discoverability and maintainability.

❌ BAD: Separate tests/ directory

src/
  components/
    Button.tsx
tests/
  components/
    Button.test.tsx

✅ GOOD: Colocated __tests__/ or .test.ts

src/
  components/
    Button/
      index.tsx
      __tests__/
        Button.test.tsx
  utils/
    formatDate.ts
    formatDate.test.ts

Read the full file on GitHub · 371 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 371 lines · 2,543 tokens per session scan A 38701ecda85f

Subscribe to this mod's changes

jest is a cursor rule published in the GitHub repository sanjeed5/awesome-cursor-rules-mdc (3,571 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 2,543 tokens to every session, about $0.0127 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.