Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,7 @@ Some errors are masked and hidden away because of the layers of abstraction and
In many test cases, we need to mock dependencies using `link:` and `file:` protocols. `pnpm` treats `link:` as symlinks and `file:` as hardlinks. To test dependencies as if they were copied into `node_modules`, use the `file:` protocol. Otherwise, use the `link:` protocol.

For a mock dependency, make sure you add a `@vitejs/test-` prefix to the package name. This will avoid possible issues like false-positive alerts.

## Contributing to `@vitejs/plugin-rsc`

See [CONTRIBUTING.md](packages/plugin-rsc/CONTRIBUTING.md) in the `@vitejs/plugin-rsc` package for specific guidelines on contributing to the React Server Components plugin.
63 changes: 63 additions & 0 deletions packages/plugin-rsc/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Contributing to @vitejs/plugin-rsc

This guide provides essential tips for contributors working on the RSC plugin.

## Testing

### E2E Test Setup

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

#### Test Fixture Patterns

- `examples/basic` - comprehensive test suite for the RSC plugin
- `examples/starter` - lightweight base template for writing more targeted tests using `setupInlineFixture` utility
- `examples/e2e/temp/` - base directory for test projects

### Adding New Test Cases

**Expanding `examples/basic` (for comprehensive features)**
Best for features that should be part of the main test suite. `examples/basic` is mainly used for e2e testing:

1. Add your test case files to `examples/basic/src/routes/`
2. Update the routing in `examples/basic/src/routes/root.tsx`
3. Add corresponding tests in `e2e/basic.test.ts`

**Using `setupInlineFixture` (for specific edge cases)**
Best for testing specific edge cases or isolated features. See `e2e/ssr-thenable.test.ts` for the pattern.

<!-- TODO: mention unit test -->

## Development Workflow

<!-- TODO: mention playwright vscode extension? -->

```bash
# Build packages
pnpm dev # pnpm -C packages/plugin-rsc dev

# Run examples
pnpm -C packages/plugin-rsc/examples/basic dev # build / preview
pnpm -C packages/plugin-rsc/examples/starter dev # build / preview

# Run all e2e tests
pnpm -C packages/plugin-rsc test-e2e

# Run with UI (this allows filtering interactively)
pnpm -C packages/plugin-rsc test-e2e --ui

# Run specific test file
pnpm -C packages/plugin-rsc test-e2e basic

# Run with filter/grep
pnpm -C packages/plugin-rsc test-e2e -g "hmr"

# Test projects created with `setupInlineFixture` are locally runnable. For example:
pnpm -C packages/plugin-rsc/examples/e2e/temp/react-compiler dev
```

## Tips

- Prefer `setupInlineFixture` for new tests - it's more maintainable and faster
- The `examples/basic` project contains comprehensive test scenarios
- Dependencies for temp test projects are managed in `examples/e2e/package.json`
Loading