agentleFS
MicrosoftKnown publishermicrosoft/data-formulator/.cursor/rules/frontend-test-conventions.mdc

data-formulator / rules

Cursor rule18k starsChanged 7 months agoMITView on GitHub

Frontend TypeScript test conventions (Vitest)

Trending

Steady talk.about the whole repository

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

Who's talking about microsoft/data-formulator

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

See all 31

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

On Bluesky · 22

17 more on Bluesky

On GitHub · 7

2 more on GitHub

The file

We split this frontend-test-conventions.mdc into the rules it gives an agent

7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Place tests under tests/frontend/unit/ mirroring the src/ structure:

    line 11
  2. Very specific:

    Import describe, it, expect explicitly from vitest (globals are enabled but explicit imports improve readability).

    line 35
  3. Very specific:

    Use @testing-library/react and @testing-library/jest-dom for component rendering tests.

    line 36
  4. Distinctive:

    Prefer testing exported pure functions over testing internal component state.

    line 37
  5. Distinctive:

    When component logic is complex, extract it into an exported helper and test that directly.

    line 38
  6. Very specific:

    Do not import from node_modules internals.

    line 41
  7. Very specific:

    Keep tests independent — no shared mutable state between it blocks.

    line 42

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 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
frontend-test-conventions.mdc
---
description: Frontend TypeScript test conventions (Vitest)
globs: tests/frontend/**/*.test.{ts,tsx}
alwaysApply: false
---

# Frontend Test Conventions

## File Location & Naming

- Place tests under `tests/frontend/unit/` mirroring the `src/` structure:
  - `tests/frontend/unit/data/` → tests for `src/data/`
  - `tests/frontend/unit/app/` → tests for `src/app/`
  - `tests/frontend/unit/views/` → tests for `src/views/`
- Name files `<functionOrFeature>.test.ts` (or `.test.tsx` for React rendering tests).

## File Structure

```typescript
import { describe, it, expect } from 'vitest';
// For React rendering tests:
// import { render } from '@testing-library/react';

import { myFunction } from '../../../../src/<path>';

describe('myFunction', () => {
  it('should handle <specific case>', () => {
    expect(myFunction(input)).toBe(expected);
  });
});
```

## Conventions

- Import `describe`, `it`, `expect` explicitly from `vitest` (globals are enabled but explicit imports improve readability).
- Use `@testing-library/react` and `@testing-library/jest-dom` for component rendering tests.
- Prefer testing **exported pure functions** over testing internal component state.
- When component logic is complex, extract it into an exported helper and test that directly.
- Group tests with `describe` blocks; use section comments (`// --- Null cases ---`) for clarity.
- One assertion per `it` block when possible; name tests as `should <expected behavior>`.
- Do **not** import from `node_modules` internals; only use public API.
- Keep tests independent — no shared mutable state between `it` blocks.

## Example

```typescript
// ❌ BAD – no describe, vague test name
import { expect, test } from 'vitest';
test('works', () => { expect(fn(1)).toBe(2); });

// ✅ GOOD
import { describe, it, expect } from 'vitest';
import { checkIsLikelyTextOnlyModel } from '../../../../src/views/DataLoadingThread';

describe('checkIsLikelyTextOnlyModel', () => {
  it('returns true for deepseek-chat', () => {
    expect(checkIsLikelyTextOnlyModel('deepseek-chat')).toBe(true);
  });

  it('returns false for undefined', () => {
    expect(checkIsLikelyTextOnlyModel(undefined)).toBe(false);
  });
});
```

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.