|
| 1 | +# Contributing to @vitejs/plugin-rsc |
| 2 | + |
| 3 | +This guide provides essential tips for contributors working on the RSC plugin. |
| 4 | + |
| 5 | +## Testing |
| 6 | + |
| 7 | +### E2E Test Setup |
| 8 | + |
| 9 | +Tests use Playwright and are located in `e2e/` and use `examples` as test apps. |
| 10 | + |
| 11 | +#### Test Fixture Patterns |
| 12 | + |
| 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 |
| 16 | + |
| 17 | +### Adding New Test Cases |
| 18 | + |
| 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: |
| 21 | + |
| 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` |
| 25 | + |
| 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. |
| 28 | + |
| 29 | +<!-- TODO: mention unit test --> |
| 30 | + |
| 31 | +## Development Workflow |
| 32 | + |
| 33 | +<!-- TODO: mention playwright vscode extension? --> |
| 34 | + |
| 35 | +```bash |
| 36 | +# Build packages |
| 37 | +pnpm dev # pnpm -C packages/plugin-rsc dev |
| 38 | + |
| 39 | +# Run examples |
| 40 | +pnpm -C packages/plugin-rsc/examples/basic dev # build / preview |
| 41 | +pnpm -C packages/plugin-rsc/examples/starter dev # build / preview |
| 42 | + |
| 43 | +# Run all e2e tests |
| 44 | +pnpm -C packages/plugin-rsc test-e2e |
| 45 | + |
| 46 | +# Run with UI (this allows filtering interactively) |
| 47 | +pnpm -C packages/plugin-rsc test-e2e --ui |
| 48 | + |
| 49 | +# Run specific test file |
| 50 | +pnpm -C packages/plugin-rsc test-e2e basic |
| 51 | + |
| 52 | +# Run with filter/grep |
| 53 | +pnpm -C packages/plugin-rsc test-e2e -g "hmr" |
| 54 | + |
| 55 | +# Test projects created with `setupInlineFixture` are locally runnable. For example: |
| 56 | +pnpm -C packages/plugin-rsc/examples/e2e/temp/react-compiler dev |
| 57 | +``` |
| 58 | + |
| 59 | +## Tips |
| 60 | + |
| 61 | +- Prefer `setupInlineFixture` for new tests - it's more maintainable and faster |
| 62 | +- The `examples/basic` project contains comprehensive test scenarios |
| 63 | +- Dependencies for temp test projects are managed in `examples/e2e/package.json` |
0 commit comments