You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Playwright E2E testing via cypress-on-rails gem
- Add cypress-on-rails gem (v1.19) with Playwright support
- Generate Playwright configuration and test structure using gem generator
- Create React on Rails specific E2E tests for components and SSR
- Add comprehensive documentation in CLAUDE.md for Playwright usage
- Include detailed README in e2e directory with examples
- Configure Rails integration for database control and factory_bot
This implementation leverages the cypress-on-rails gem to provide:
- Seamless Rails integration with database cleanup between tests
- Factory Bot support for easy test data creation
- Ability to run arbitrary Ruby code from Playwright tests
- Predefined scenarios for complex application states
- Better developer experience than standalone Playwright
Tests demonstrate React on Rails features: server-side rendering,
client-side hydration, Redux integration, and component interactivity.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Copy file name to clipboardExpand all lines: CLAUDE.md
+131Lines changed: 131 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ Git hooks will automatically run linting on **all changed files (staged + unstag
27
27
-**Run tests**:
28
28
- Ruby tests: `rake run_rspec`
29
29
- JavaScript tests: `yarn run test` or `rake js_tests`
30
+
- Playwright E2E tests: See Playwright section below
30
31
- All tests: `rake` (default task runs lint and all tests except examples)
31
32
-**Linting** (MANDATORY BEFORE EVERY COMMIT):
32
33
-**REQUIRED**: `bundle exec rubocop` - Must pass with zero offenses
@@ -126,10 +127,140 @@ This project maintains both a Ruby gem and an NPM package:
126
127
- Generated examples are in `gen-examples/` (ignored by git)
127
128
- Only use `yarn` as the JS package manager, never `npm`
128
129
130
+
## Playwright E2E Testing
131
+
132
+
### Overview
133
+
Playwright E2E testing is integrated via the `cypress-on-rails` gem (v1.19+), which provides seamless integration between Playwright and Rails. This allows you to control Rails application state during tests, use factory_bot, and more.
134
+
135
+
### Setup
136
+
The gem and Playwright are already configured. To install Playwright browsers:
137
+
138
+
```bash
139
+
cd spec/dummy
140
+
yarn playwright install --with-deps
141
+
```
142
+
143
+
### Running Playwright Tests
144
+
145
+
```bash
146
+
cd spec/dummy
147
+
148
+
# Run all tests
149
+
yarn playwright test
150
+
151
+
# Run tests in UI mode (interactive debugging)
152
+
yarn playwright test --ui
153
+
154
+
# Run tests with visible browser
155
+
yarn playwright test --headed
156
+
157
+
# Debug a specific test
158
+
yarn playwright test --debug
159
+
160
+
# Run specific test file
161
+
yarn playwright test e2e/playwright/e2e/react_on_rails/basic_components.spec.js
162
+
```
163
+
164
+
### Writing Tests
165
+
166
+
Tests are located in `spec/dummy/e2e/playwright/e2e/`. The gem provides helpful commands for Rails integration:
0 commit comments