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.
npx agentmods add rules/golid-ai/golid/write-tests-frontendgit clone --depth 1 https://github.com/golid-ai/golidWrote 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/golid-ai/golid/write-tests-frontend)<a href="https://agentmods.dev/rules/golid-ai/golid/write-tests-frontend"><img src="https://agentmods.dev/badge/rules/golid-ai/golid/write-tests-frontend.svg" alt="Measured on agentmods" 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 | $0.00000 | $0.01088 |
| Opus 5 | $0.00000 | $0.00544 |
| Sonnet 5 | $0.00000 | $0.00218 |
| Haiku 4.5 | $0.00000 | $0.00109 |
Grade A, and why
write-tests-frontend 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 5d 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 — 117 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Writing Frontend Component Tests
Thesis: Frontend tests verify behavior through props, callbacks, and rendered content — not rendering existence alone. Know jsdom's limits.
Before writing tests for a module, read docs/modules/{module}/spec.md
for the Critical Test Scenarios section — it's a verified test plan.
Always Test Error Paths
Don't just test happy paths. Every service method should have tests for:
- Permission denied — wrong user type, non-owner, non-member → expect
FORBIDDEN - Invalid status — operation on wrong-status entity → expect
BAD_REQUEST - Not found — non-existent ID → expect
NOT_FOUND - Duplicate/conflict — re-creating existing entity → expect
CONFLICT
These are the bugs that slip through manual testing and break in production.
This section is intentionally duplicated in
write-tests.mdcandwrite-tests-frontend.mdc. If updated, change both.
Component Unit Tests (SolidJS)
Use @solidjs/testing-library for component-level tests. Test the public API: renders, accepts props, fires events.
import { afterEach } from "vitest";
import { cleanup, render, screen, fireEvent } from "@solidjs/testing-library";
import { Button } from "./Button";
afterEach(cleanup);
test("calls onClick", async () => {
const handler = vi.fn();
render(() => <Button onClick={handler}>Click</Button>);
await fireEvent.click(screen.getByText("Click"));
expect(handler).toHaveBeenCalledTimes(1);
});
Place test files next to the component: Button.test.tsx alongside Button.tsx. Vitest discovers src/**/*.test.{ts,tsx} automatically.
Important: vitest.config.ts must have resolve.conditions: ["development", "browser"] to prevent Solid from resolving server-side bundles in jsdom.
Always call afterEach(cleanup) in *.test.tsx files that use
@solidjs/testing-library. Without cleanup, previous renders can leak Solid
computations into the next test and emit "computations created outside a root"
warnings.
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.
- 5d ago First seen · 117 lines · 0 tokens per session scan A b9485b7b157d
write-tests-frontend is a cursor rule published in the GitHub repository golid-ai/golid (40 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,088 tokens. 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-08-30.
Other cursor rules, from other repositories
unit-tests-tdd
TDD for behavior changes; co-located tests; keep touched areas well covered.
go-testing-practices
Go Testing Best Practices.
unit-tests-tdd
TDD required for behavior changes; ≥80% package coverage on touched packages; unit-test conventions.
state-management
Use the following stack. Do not introduce or recommend Redux or React Context for shared/global state.
python-general-coding-standards
应用一般 Python 编码标准,包括类型提示、使用 Pydantic 进行输入验证、后台任务、CORS 处理、安全工具、PEP 8 合规性和全面测试。.
unit-testing-standards
Cursor rule "unit-testing-standards" from adobecom/da-express-milo, covering unit testing standards, testing philosophy, testing framework stack, test structure patterns and 1. standard test file organization.