agentleFS
solidjssolidjs/solid/.cursor/rules/testing-patterns.mdc

solid / rules

Cursor rule37k starsChanged 12 days agoMITView on GitHub

Test conventions and patterns for the SolidJS monorepo

Trending

More talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 2 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 7 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the solidjs/solid repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about solidjs/solid

The biggest 5 of 21 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 21

Talked about on YouTube, Hacker News, GitHub and Bluesky (21 times).

On YouTube · 7

2 more on YouTube

On Hacker News · 5

On GitHub · 5

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 4,373 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository4 other files it gives its agents.

The file

We split this testing-patterns.mdc into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always capture the disposer for cleanup.

    line 40
  2. Very specific:

    Use JSX inside createRoot, capture elements via ref:

    line 58

≈ “Common” is an estimate: at least 1 in 5 of the 7,324 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
testing-patterns.mdc
---
description: Test conventions and patterns for the SolidJS monorepo
globs: packages/*/test/**
alwaysApply: false
---

# Testing Patterns

## Setup

Vitest with globals enabled — `describe`, `test`, `expect`, `vi` are available without imports. Environment is `jsdom` (set per-file via `/** @vitest-environment jsdom */` directive or in config).

JSX files use the `@jsxImportSource solid-js` directive.

## Flush After Writes

Updates are batched via `@solidjs/signals`. Signal writes do NOT take effect until `flush()`:

```typescript
const [count, setCount] = createSignal(0);
setCount(1);
expect(count()).toBe(0); // Not flushed yet
flush();
expect(count()).toBe(1); // Now updated
```

## Reactive Roots

Effects and computations need `createRoot` for ownership:

```typescript
let disposer: () => void;
createRoot(dispose => {
  disposer = dispose;
  createEffect(signal, value => { /* ... */ });
});
flush();
```

Always capture the disposer for cleanup.

## Effect Testing

Effects separate compute and effect functions. Compute runs synchronously on creation; the effect callback runs after flush:

```typescript
const compute = vi.fn(signal);
const effect = vi.fn();
createRoot(() => createEffect(compute, effect));
expect(compute).toHaveBeenCalledTimes(1);
expect(effect).toHaveBeenCalledTimes(0);
flush();
expect(effect).toHaveBeenCalledTimes(1);
```

## DOM / Component Testing

Use JSX inside `createRoot`, capture elements via `ref`:

```typescript
let div!: HTMLDivElement, disposer: () => void;
const Component = () => (
  <div ref={div}>
    <Show when={count() >= 5}>{count()}</Show>
  </div>
);

test("renders conditionally", () => {
  createRoot(dispose => {
    disposer = dispose;
    <Component />;
  });
  expect(div.innerHTML).toBe("");
  setCount(7);
  flush();
  expect(div.innerHTML).toBe("7");
});

test("dispose", () => disposer());
```

## Common Assertions

- `div.innerHTML` for content
- `querySelector` / `querySelectorAll` for element queries
- `instanceof` checks for element types
- `textContent` for text nodes
- `vi.fn()` for spy/mock tracking

## Test File Organization

- `packages/solid/test/` — reactive primitives (signals, effects, memos, context, owner)
- `packages/web/test/` — DOM rendering, flow controls, Portal, Dynamic
- `packages/test-integration/` — integration tests against external repos
- Type tests in `.type-tests.ts` files using `@ts-expect-error` for negative cases

## Imports

```typescript
// Reactive primitives
import { createSignal, createMemo, createEffect, createRoot, flush } from "solid-js";

// DOM utilities
import { render, insert, clearDelegatedEvents } from "@solidjs/web";

// Flow controls
import { For, Show, Switch, Match } from "solid-js";
```

## Commands

- `pnpm test` — all tests + type tests via Turborepo
- `pnpm coverage` — coverage reports (v8 provider, lcov)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.