Skip to content

Commit 5954659

Browse files
hi-ogawaOpenCode
andauthored
chore(rsc): rework testing guidance (#1293)
Co-authored-by: Hiroshi Ogawa <4232207+hi-ogawa@users.noreply.github.com> Co-authored-by: OpenCode <noreply@opencode.ai>
1 parent 674c6c4 commit 5954659

2 files changed

Lines changed: 24 additions & 24 deletions

File tree

packages/plugin-rsc/AGENTS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ This document provides AI-agent-specific guidance for the React Server Component
55
- **[README.md](README.md)** - Plugin overview, concepts, and examples
66
- **[CONTRIBUTING.md](CONTRIBUTING.md)** - Development setup and testing guidelines
77

8+
Before adding integration coverage, follow the test fixture guidance in [CONTRIBUTING.md](CONTRIBUTING.md#choosing-a-test-fixture).
9+
810
## Quick Reference for AI Agents
911

1012
### Essential Commands
@@ -13,7 +15,6 @@ This document provides AI-agent-specific guidance for the React Server Component
1315
# inside packages/plugin-rsc directory
1416
pnpm build # build package
1517
pnpm tsc # typecheck
16-
pnpm dev # Watch mode development
18+
pnpm test # Run unit tests
1719
pnpm test-e2e # Run e2e tests
18-
pnpm test-e2e basic # Test specific example
1920
```

packages/plugin-rsc/CONTRIBUTING.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,35 @@ This guide provides essential tips for contributors working on the RSC plugin.
44

55
## Testing
66

7-
### E2E Test Setup
7+
### End-to-End Tests
88

99
Tests use Playwright and are located in `e2e/` and use `examples` as test apps.
1010

11-
#### Test Fixture Patterns
11+
Avoid reducing plugin or runtime behavior to mocked unit tests. Craft E2E coverage that clearly demonstrates the relevant RSC bundler semantics.
1212

13-
- `examples/basic` - comprehensive test suite for the RSC plugin
14-
- `examples/starter` - lightweight base template for writing more targeted tests using `setupInlineFixture` utility
15-
- `examples/e2e/temp/` - base directory for test projects
13+
#### Choosing a Test Fixture
1614

17-
### Adding New Test Cases
15+
**Adding a dedicated example**
1816

19-
**Expanding `examples/basic` (for comprehensive features)**
20-
Best for features that should be part of the main test suite. `examples/basic` is mainly used for e2e testing:
17+
Prefer a runnable app under `examples/<feature>` for substantial end-to-end behavior. Add a corresponding thin test under `e2e/` and cover both development and production build modes when applicable.
2118

22-
1. Add your test case files to `examples/basic/src/routes/`
23-
2. Update the routing in `examples/basic/src/routes/root.tsx`
24-
3. Add corresponding tests in `e2e/basic.test.ts`
19+
**Expanding `examples/basic`**
2520

26-
**Using `setupInlineFixture` (for specific edge cases)**
27-
Best for testing specific edge cases or isolated features. See `e2e/ssr-thenable.test.ts` for the pattern.
21+
Use `examples/basic`, which contains comprehensive test scenarios, when the case is a small extension of the existing application and does not require distinct configuration or framework behavior:
2822

29-
<!-- TODO: mention unit test -->
23+
1. Add the test case files to `examples/basic/src/routes/`.
24+
2. Update the routing in `examples/basic/src/routes/root.tsx`.
25+
3. Add corresponding tests in `e2e/basic.test.ts`.
3026

31-
## Development Workflow
27+
**Using `setupInlineFixture`**
28+
29+
Use `setupInlineFixture` with `examples/starter` for narrow configuration variants, invalid-input coverage, and cases where a standalone runnable example would add mostly boilerplate. Test projects are written under `examples/e2e/temp/`, with dependencies managed in `examples/e2e/package.json`. See `e2e/ssr-thenable.test.ts` for the pattern.
30+
31+
### Unit Tests
32+
33+
Use colocated unit tests for self-contained transforms and utilities.
3234

33-
<!-- TODO: mention playwright vscode extension? -->
35+
## Development Workflow
3436

3537
```bash
3638
# Build packages
@@ -39,6 +41,9 @@ pnpm dev # pnpm -C packages/plugin-rsc dev
3941
# Type check
4042
pnpm -C packages/plugin-rsc tsc-dev
4143

44+
# Run unit tests
45+
pnpm -C packages/plugin-rsc test --run
46+
4247
# Run examples
4348
pnpm -C packages/plugin-rsc/examples/basic dev # build / preview
4449
pnpm -C packages/plugin-rsc/examples/starter dev # build / preview
@@ -58,9 +63,3 @@ pnpm -C packages/plugin-rsc test-e2e -g "hmr"
5863
# Test projects created with `setupInlineFixture` are locally runnable. For example:
5964
pnpm -C packages/plugin-rsc/examples/e2e/temp/react-compiler dev
6065
```
61-
62-
## Tips
63-
64-
- Prefer `setupInlineFixture` for new tests - it's more maintainable and faster
65-
- The `examples/basic` project contains comprehensive test scenarios
66-
- Dependencies for temp test projects are managed in `examples/e2e/package.json`

0 commit comments

Comments
 (0)