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
Copy file name to clipboardExpand all lines: CLAUDE.md
+32-12Lines changed: 32 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,26 +95,43 @@ motion (public API)
95
95
96
96
1.**Create a test page** in `dev/react/src/tests/<test-name>.tsx` exporting a named `App` component. It's automatically available at `?test=<test-name>`.
97
97
2.**Create a spec** in `packages/framer-motion/cypress/integration/<test-name>.ts`.
98
-
3.**Verify WAAPI acceleration** using `element.getAnimations()` in Cypress `should` callbacks to check that native animations are (or aren't) created.
98
+
3.**Verify WAAPI acceleration** using `element.getAnimations()` in Cypress callbacks — but **only for compositor properties** (opacity, transform). `getAnimations()` won't return WAAPI animations for non-compositor properties like height/width in Electron. Don't use it for those.
99
+
100
+
### Cypress animation testing patterns
101
+
102
+
-**Use `.then()`, not `.should()`, for mid-animation measurements.**`cy.should()` retries assertions until they pass or timeout — so it will keep retrying until the animation completes, masking bugs where the target value is wrong. `.then()` captures the value at a single point in time.
103
+
-**For animation target bugs, use long duration + linear easing + mid-animation measurement.** Set `transition={{ type: "tween", ease: "linear", duration: 10 }}`, wait 5s (50% through), then check the computed style with `.then()`. If the target is wrong, the value will be proportionally wrong and easy to detect.
104
+
-**Don't try `getAnimations()` for non-compositor properties** (height, width, etc.) in Cypress/Electron. It likely won't have WAAPI animations to inspect. Stick to computed style checks for these.
105
+
-**Don't use `onUpdate` for mid-animation pixel values.** For keyword targets like `"auto"`, `onUpdate` reports the keyword, not the resolved pixel value. Use `getComputedStyle()` instead.
106
+
-**Always run Cypress tests in the foreground.** Background bash commands hang silently and produce empty output, making debugging impossible. Cypress needs reliable stdout/stderr.
99
107
100
108
### Running Cypress tests locally
101
109
102
110
**You MUST run every new Cypress test against both React 18 and React 19 before creating a PR.** CI runs both and will break if you skip this.
103
111
104
-
Use the `test-single` pattern from the Makefile, adapted per spec. **Always pick a unique port** using `$RANDOM` to avoid conflicts when multiple agents run tests concurrently:
112
+
**Start the Vite dev server directly** — do NOT use `yarn start-server-and-test` with `yarn dev-server` (turbo). Turbo starts ALL dev servers including Next.js, which is slow and unreliable. Starting Vite directly is instant:
105
113
106
114
```bash
107
-
# React 18 — pick a random port, override both Vite and Cypress
115
+
# React 18 — start Vite directly, then run Cypress
cd dev/react-19 && TEST_PORT=$PORT yarn vite --port $PORT&
127
+
DEV_PID=$!
128
+
npx wait-on http://localhost:$PORT
129
+
cd packages/framer-motion && cypress run --config-file=cypress.react-19.json --config baseUrl=http://localhost:$PORT --headed --spec cypress/integration/<test-name>.ts
130
+
kill$DEV_PID
116
131
```
117
132
133
+
**Do NOT set `TEST_PORT` globally with turbo** — it affects both React 18 and 19 dev servers, causing port conflicts. Start each server independently on its own port as shown above.
134
+
118
135
Both must pass. If a test fails on one React version but not the other, investigate — do not skip it.
119
136
120
137
### Async test helpers
@@ -143,9 +160,12 @@ async function nextFrame() {
143
160
144
161
When working on a bug fix from a GitHub issue:
145
162
146
-
1.**The reporter's reproduction code is the basis for your test.** If the issue links to a CodeSandbox/StackBlitz, fetch it. Try multiple URL patterns if the first fails. If the issue has inline code, use that directly.
147
-
2.**If you cannot get the reproduction code, STOP and ask for help.** Do not guess at what the reporter meant — that leads to tests that prove nothing. Message the team lead with the URL and ask them to provide the code.
148
-
3.**Do not proceed to a fix without a test that fails for the right reason.** See the "Writing Tests" section above.
163
+
1.**Read the issue first.** Run `gh issue view <number>` before doing anything else. Do not infer the ask from code context or agent exploration — read the actual issue to understand what's being requested.
164
+
2.**Check git history early.** Before tracing code, run `git log --grep="<keyword>" -- <relevant-file>` to see if the bug was already fixed or if prior commits reveal the root cause. This can save an entire session of manual code tracing.
165
+
3.**The reporter's reproduction code is the basis for your test.** If the issue links to a CodeSandbox/StackBlitz, fetch it. Try multiple URL patterns if the first fails. If the issue has inline code, use that directly.
166
+
4.**If you cannot get the reproduction code, STOP and ask for help.** Do not guess at what the reporter meant — that leads to tests that prove nothing. Message the team lead with the URL and ask them to provide the code.
167
+
5.**Do not proceed to a fix without a test that fails for the right reason.** See the "Writing Tests" section above.
168
+
6.**Run one clean install, then wait for it to finish.** Do not run `make bootstrap`, `yarn install`, or `corepack enable && yarn install` as overlapping background tasks — they interfere with each other. One install command, foreground, wait for completion.
0 commit comments