Getting it into your agent
It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.
git clone --depth 1 https://github.com/lambda-curry/medusa2-starternpx agentmods add rules/lambda-curry/medusa2-starter/testing-patterns-unitWrote 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.
[](https://agentmods.dev/rules/lambda-curry/medusa2-starter/testing-patterns-unit)<a href="https://agentmods.dev/rules/lambda-curry/medusa2-starter/testing-patterns-unit"><img src="https://agentmods.dev/badge/rules/lambda-curry/medusa2-starter/testing-patterns-unit/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/lambda-curry/medusa2-starter/testing-patterns-unit"><img src="https://agentmods.dev/badge/rules/lambda-curry/medusa2-starter/testing-patterns-unit.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.01532 | $0.01532 |
| Opus 5.5 | $0.00613 | $0.00613 |
| Sonnet 5.5 | $0.00306 | $0.00306 |
| Haiku 4.5 | $0.00153 | $0.00153 |
Grade A, and why
testing-patterns-unit 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 15d 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.
How it starts
The opening of the file, as written. The whole thing — 241 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Unit Testing Patterns for Medusa Applications
You are an expert in unit testing TypeScript applications, focusing on testing individual components, services, and functions in isolation for Medusa and React applications.
Core Testing Principles
- Write tests that are readable, maintainable, and reliable
- Focus on testing individual units in isolation
- Use descriptive test names that explain the behavior being tested
- Arrange, Act, Assert (AAA) pattern for test structure
- Test behavior, not implementation details
- Use proper mocking and stubbing strategies
- Ensure tests are isolated and can run independently
Unit Testing Patterns
Medusa Service Testing
// services/__tests__/UserService.test.ts
import { createMedusaContainer } from "@medusajs/framework/utils"
import { UserService } from "../UserService"
import { User } from "../models/User"
describe("UserService", () => {
let container: MedusaContainer
let userService: UserService
let mockRepository: jest.Mocked<any>
beforeEach(() => {
container = createMedusaContainer()
mockRepository = {
create: jest.fn(),
findOne: jest.fn(),
update: jest.fn(),
delete: jest.fn(),
}
container.register("userRepository", mockRepository)
userService = container.resolve("userService")
})
describe("create", () => {
it("should create a new user with valid data", async () => {
// Arrange
const userData = {
name: "John Doe",
email: "[email protected]",
}
const expectedUser = { id: "user_123", ...userData }
mockRepository.create.mockResolvedValue(expectedUser)
// Act
const result = await userService.create(userData)
// Assert
expect(mockRepository.create).toHaveBeenCalledWith(userData)
expect(result).toEqual(expectedUser)
})
it("should throw validation error for invalid email", async () => {
// Arrange
const invalidUserData = {
name: "John Doe",
email: "invalid-email",
}
// Act & Assert
await expect(userService.create(invalidUserData))
.rejects
.toThrow("Invalid email format")
})
})
describe("findById", () => {
it("should return user when found", async () => {
// Arrange
const userId = "user_123"
const expectedUser = { id: userId, name: "John Doe" }
mockRepository.findOne.mockResolvedValue(expectedUser)
// Act
const result = await userService.findById(userId)
// Assert
expect(mockRepository.findOne).toHaveBeenCalledWith({ id: userId })
expect(result).toEqual(expectedUser)
})
it("should return null when user not found", async () => {
// Arrange
const userId = "nonexistent"
mockRepository.findOne.mockResolvedValue(null)
// Act
const result = await userService.findById(userId)
// Assert
expect(result).toBeNull()
})
})
})
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.
- 15d ago First seen · 241 lines · 1,532 tokens per session scan A 449005f1f929
testing-patterns-unit is a cursor rule published in the GitHub repository lambda-curry/medusa2-starter (164 stars, last pushed 17d ago), licensed MIT. It adds 1,532 tokens to every session, about $0.0061 per session on Opus 5.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-11-15.
testing-patterns-unit compared with cursor rules from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| testing-patterns-unitlambda-curry/medusa2-starter | Cursor rule | 164 | 17d ago | MIT | A | 1,532 | Cursor |
| use-contract-ir-factoriesprisma/orm | Cursor rule | 48k | today | Apache-2.0 | A | 0 | Cursor |
| mockitosanjeed5/awesome-cursor-rules-mdc | Cursor rule | 3.6k | 7d ago | CC0-1.0 | A | 1,653 | Cursor |
| gonavi-goSyngnat/GoNavi | Cursor rule | 2.1k | today | Apache-2.0 | A | 0 | Cursor |
| python-general-coding-standardsholtwood/awesome-cursorrules-zh | Cursor rule | 244 | 1mo ago | MIT | A | 140 | Cursor |
| project-conventionskequach/uniqlo-sales-alerter | Cursor rule | 32 | yesterday | MIT | A | 1,033 | Cursor |
| spec-for-utdtyq/magic | Cursor rule | 5.1k | 1mo ago | none | A | 528 | Cursor |