RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Diff/storybookjs-storybook-cursorrules ↔ storybookjs-storybook-cursor-rules-spy-mocking

Comparison

A · .cursorrules · storybookjs/storybookB · Cursor rules · storybookjs/storybook
What each file covers, counted
DimensionSharedOnly in AOnly in BOverlap
Sections0850%
Commands0500%
Section tags32150%

What each file covers

Sections

0 shared · 8 only in A · 5 only in B
  • − Test Configuration
  • − Test Scripts
  • − Test Directory Structure
  • − Running Tests in Cursor
  • − Vitest Configuration
  • − Test Execution Context
  • − Focused Test Patterns
  • − Test Mocking Rules
  • + Spy Mocking Rules for Vitest Tests
  • + Mocking Approach
  • + Mock Implementation Rules
  • + Avoided Patterns
  • + Best Practices

Commands

0 shared · 5 only in A · 0 only in B
  • − yarn test
  • − yarn test <test-name>
  • − yarn test:watch
  • − yarn test:watch <test-name>
  • − yarn --cwd code test

Section tags

3 shared · 2 only in A · 1 only in B
  • − architecture
  • − agent-behaviour
  • + testing-strategy
  •   test
  •   code-style
  •   do-not

Line diff

+32 added−39 removed12 unchanged23.5% identical
storybookjs/storybook · .cursorrules
@@ −1 @@
1## Test Configuration
 
 
 
 
2 
3This Storybook repository uses Vitest as the test runner. Here are the key commands and configuration:
4 
5### Test Scripts
6 
7- `yarn test` - Run all tests (from root directory, delegates to `cd code; yarn test`)
8- `yarn test <test-name>` - Run focused tests matching the pattern
9- `yarn test:watch` - Run tests in watch mode
10- `yarn test:watch <test-name>` - Run focused tests in watch mode
11 
12### Test Directory Structure
 
 
 
 
13 
14- Tests are located in the `code/` directory
15- Vitest configuration is in `code/vitest.workspace.ts`
16- Test files typically follow the pattern `*.test.ts`, `*.test.tsx`, `*.spec.ts`, or `*.spec.tsx`
17 
18### Running Tests in Cursor
 
 
 
 
19 
201. Use Cmd+Shift+P (or Ctrl+Shift+P) and search for "Tasks: Run Task"
212. Select from the available test tasks:
22 - "Run All Tests" - Runs all tests
23 - "Run Test (Watch Mode)" - Runs tests in watch mode
24 - "Run Focused Test" - Prompts for test name/pattern to run specific tests
25 - "Run Focused Test (Watch Mode)" - Runs specific tests in watch mode
26 
27### Vitest Configuration
28 
29- Workspace configuration: `./code/vitest.workspace.ts`
30- Command line: `yarn --cwd code test`
31- Root directory for tests: `./code/`
 
 
32 
33### Test Execution Context
34 
35- Tests run from the `code/` directory
36- Use `NODE_OPTIONS=--max_old_space_size=4096` for memory optimization
37- Supports both watch mode and single-run execution
38 
39### Focused Test Patterns
40 
41When running focused tests, you can use:
42 
43- File names: `Button.test.ts`
44- Test descriptions: `"should render correctly"`
45- Directory patterns: `components/`
46- Vitest patterns: `-t "pattern"` for test name matching
47 
48### Test Mocking Rules
49 
50Follow the spy mocking rules defined in `.cursor/rules/spy-mocking.mdc` for consistent mocking patterns with Vitest.
51 
storybookjs/storybook · .cursor/rules/spy-mocking.mdc
@@ +1 @@
1---
2description: Rules for consistent and type-safe mocking in Vitest tests
3globs: "**/*.test.{ts,tsx,js,jsx}"
4alwaysApply: true
5---
6 
7# Spy Mocking Rules for Vitest Tests
8 
9## Mocking Approach
10 
11When mocking packages or files in Vitest-based tests, follow these rules:
 
 
 
12 
131. Use `vi.mock()` with the `spy: true` option for all package and file mocks
142. Place all mocks at the top of the test file before any test cases
153. Use `vi.mocked()` to type and access the mocked functions
164. Implement mock behaviors in `beforeEach` blocks
175. Mock all required dependencies that the test subject uses
18 
19## Mock Implementation Rules
 
 
20 
211. Mock implementations should be placed in `beforeEach` blocks
222. Each mock implementation should return a Promise for async functions
233. Mock implementations should match the expected return type of the original function
244. Use `vi.mocked()` to access and implement mock behaviors
255. Mock all required properties and methods that the test subject uses
26 
27## Avoided Patterns
 
 
 
 
 
28 
29The following mocking patterns should be avoided:
30 
311. Direct function mocking without `vi.mocked()`
322. Mock implementations outside of `beforeEach` blocks
333. Mocking without the `spy: true` option
344. Inline mock implementations within test cases
355. Mocking only a subset of required dependencies
36 
37## Best Practices
38 
391. Mock at the highest level of abstraction needed
402. Keep mock implementations simple and focused
413. Use type-safe mocking with `vi.mocked()`
424. Document complex mock behaviors
435. Group related mocks together
 
 
 
 
 
 
 
 
 
 
 
44 
@@ −1 +1 @@
1−## Test Configuration
1+---
2+description: Rules for consistent and type-safe mocking in Vitest tests
3+globs: "**/*.test.{ts,tsx,js,jsx}"
4+alwaysApply: true
5+---
26  
3−This Storybook repository uses Vitest as the test runner. Here are the key commands and configuration:
7+# Spy Mocking Rules for Vitest Tests
48  
5−### Test Scripts
9+## Mocking Approach
610  
7−- `yarn test` - Run all tests (from root directory, delegates to `cd code; yarn test`)
8−- `yarn test <test-name>` - Run focused tests matching the pattern
9−- `yarn test:watch` - Run tests in watch mode
10−- `yarn test:watch <test-name>` - Run focused tests in watch mode
11+When mocking packages or files in Vitest-based tests, follow these rules:
1112  
12−### Test Directory Structure
13+1. Use `vi.mock()` with the `spy: true` option for all package and file mocks
14+2. Place all mocks at the top of the test file before any test cases
15+3. Use `vi.mocked()` to type and access the mocked functions
16+4. Implement mock behaviors in `beforeEach` blocks
17+5. Mock all required dependencies that the test subject uses
1318  
14−- Tests are located in the `code/` directory
15−- Vitest configuration is in `code/vitest.workspace.ts`
16−- Test files typically follow the pattern `*.test.ts`, `*.test.tsx`, `*.spec.ts`, or `*.spec.tsx`
19+## Mock Implementation Rules
1720  
18−### Running Tests in Cursor
21+1. Mock implementations should be placed in `beforeEach` blocks
22+2. Each mock implementation should return a Promise for async functions
23+3. Mock implementations should match the expected return type of the original function
24+4. Use `vi.mocked()` to access and implement mock behaviors
25+5. Mock all required properties and methods that the test subject uses
1926  
20−1. Use Cmd+Shift+P (or Ctrl+Shift+P) and search for "Tasks: Run Task"
21−2. Select from the available test tasks:
22− - "Run All Tests" - Runs all tests
23− - "Run Test (Watch Mode)" - Runs tests in watch mode
24− - "Run Focused Test" - Prompts for test name/pattern to run specific tests
25− - "Run Focused Test (Watch Mode)" - Runs specific tests in watch mode
27+## Avoided Patterns
2628  
27−### Vitest Configuration
29+The following mocking patterns should be avoided:
2830  
29−- Workspace configuration: `./code/vitest.workspace.ts`
30−- Command line: `yarn --cwd code test`
31−- Root directory for tests: `./code/`
31+1. Direct function mocking without `vi.mocked()`
32+2. Mock implementations outside of `beforeEach` blocks
33+3. Mocking without the `spy: true` option
34+4. Inline mock implementations within test cases
35+5. Mocking only a subset of required dependencies
3236  
33−### Test Execution Context
37+## Best Practices
3438  
35−- Tests run from the `code/` directory
36−- Use `NODE_OPTIONS=--max_old_space_size=4096` for memory optimization
37−- Supports both watch mode and single-run execution
38− 
39−### Focused Test Patterns
40− 
41−When running focused tests, you can use:
42− 
43−- File names: `Button.test.ts`
44−- Test descriptions: `"should render correctly"`
45−- Directory patterns: `components/`
46−- Vitest patterns: `-t "pattern"` for test name matching
47− 
48−### Test Mocking Rules
49− 
50−Follow the spy mocking rules defined in `.cursor/rules/spy-mocking.mdc` for consistent mocking patterns with Vitest.
39+1. Mock at the highest level of abstraction needed
40+2. Keep mock implementations simple and focused
41+3. Use type-safe mocking with `vi.mocked()`
42+4. Document complex mock behaviors
43+5. Group related mocks together
5144  
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack