|
| 1 | +# Agent guidance for sentry-electron |
| 2 | + |
| 3 | +## Running the e2e tests |
| 4 | + |
| 5 | +The end-to-end tests in [`test/e2e`](./test/e2e) launch real Electron apps. A few things are required to run them |
| 6 | +successfully, especially from an agent shell such as Claude Code: |
| 7 | + |
| 8 | +- **`unset ELECTRON_RUN_AS_NODE` first.** Some agent shells, such as Claude Code, export `ELECTRON_RUN_AS_NODE=1`, |
| 9 | + which makes every Electron binary run as plain Node. When that happens `require('electron').app` is `undefined` and |
| 10 | + every test crashes at SDK load (`normalize.js` calling `app.getAppPath()`) or times out. This is not a broken |
| 11 | + harness — it only affects shells where that variable is set. |
| 12 | +- **Set `ELECTRON_VERSION`.** The runner throws `ELECTRON_VERSION is not set` otherwise. The SDK needs Electron 35 or |
| 13 | + higher, so use a version in that range whose binary is already cached (e.g. `39.8.10`). |
| 14 | +- **Build and pack the SDK first.** The test apps install `sentry-electron-v<version>.tgz` from the repo root, and |
| 15 | + `yarn e2e` does not create it. Run `yarn build && yarn pack` after each change to `src`. |
| 16 | +- **Use `yarn e2e`, not a bare `vitest` invocation.** `yarn e2e` runs the `pree2e` step (`set-version`, cache cleanup) |
| 17 | + that the tests depend on. |
| 18 | +- **`-t` is a regex**, so escape parentheses in test names, e.g. `-t 'Browser Tracing \(Span streaming\)'`. |
| 19 | +- **`DEBUG=true`** prints every received envelope as `[Test Runner] Received event ...`, which is the easiest way to |
| 20 | + build/verify assertions. |
| 21 | + |
| 22 | +Example — run all span-streaming tests against Electron 39.8.10: |
| 23 | + |
| 24 | +```shell |
| 25 | +unset ELECTRON_RUN_AS_NODE |
| 26 | +yarn build && yarn pack |
| 27 | +DEBUG=true ELECTRON_VERSION=39.8.10 yarn e2e -t 'Span streaming' |
| 28 | +``` |
0 commit comments