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
{{ message }}
Repository navigation
Commit 5670fea
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: packages/relay-e2e-test/.llms/skills/relay-e2e-test/references/writing-fixtures.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -166,6 +166,30 @@ Every fixture runs twice, on graphql 16 and on graphql 17 (see `jest.config.js`)
166
166
167
167
Always commit the `.snap.md` alongside the fixture. Jest treats a CI environment as `--ci` automatically (via `ci-info`, which checks `CI` among others), so a fixture landed without its snapshot fails there rather than silently writing one and passing forever.
168
168
169
+
### Expected runtime errors
170
+
171
+
An uncaught error fails the test: for example, an error that React reports when it renders after an update or a Suspense retry, or an error thrown by an event handler. To pin a known runtime bug instead, make this the first line of the fixture, like the comment that marks a Relay compiler fixture that expects an error:
172
+
173
+
```
174
+
// expected-to-throw
175
+
```
176
+
177
+
A marked fixture passes only if an uncaught error occurs while the app renders or runs its steps. The harness writes the error into a `## Runtime Error` section of the snapshot, after `## Type Errors`:
178
+
179
+
````markdown
180
+
## Runtime Error
181
+
182
+
```
183
+
Invariant Violation: Expected to find record for live resolver.
184
+
```
185
+
````
186
+
187
+
If no uncaught error occurs, the fixture fails. So when the bug is fixed, remove the first line and update the snapshot. The marker counts only on the first line.
188
+
189
+
After the error, React has unmounted the app, so the harness does not report a step that fails after it. Write the steps for the behavior you expect once the bug is fixed (for example, end with a `wait` for the correct result), so the error occurs while they run. Compile errors, type errors, and a step that fails before the error are reported as usual. An error that React throws back into the test inside `act()` (for example, from the first render) also fails the test as usual, and an error that an error boundary catches is not uncaught.
190
+
191
+
`fixtures/gc/abstract-client-edge.md` is the worked example.
192
+
169
193
## Relay docs
170
194
171
195
To understand how Relay APIs work, consult the Relay docs source files:
Copy file name to clipboardExpand all lines: packages/relay-e2e-test/README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,10 @@ Each fixture is typechecked with `tsc` after the Relay compiler runs, against th
63
63
64
64
The repo's other TypeScript check, `yarn typecheck:ts`, only verifies that `relay-runtime`'s declarations are internally well-formed. The e2e suite is what checks they are actually *usable*.
65
65
66
+
## Expected runtime errors
67
+
68
+
An uncaught error fails a fixture. A fixture whose first line is `// expected-to-throw` (the comment that marks a Relay compiler fixture that expects an error) passes only if one occurs, and the error is written into a `## Runtime Error` section of its snapshot. Use it to pin a known runtime bug until it is fixed — see the [writing guide](.llms/skills/relay-e2e-test/references/writing-fixtures.md#expected-runtime-errors).
69
+
66
70
## Writing fixtures
67
71
68
72
For the complete writing guide including fixture format, server/client code patterns, the interaction DSL, and snapshot behavior, see [`.llms/skills/relay-e2e-test/SKILL.md`](.llms/skills/relay-e2e-test/SKILL.md).
0 commit comments