The end-to-end tests in test/e2e launch real Electron apps. A few things are required to run them
successfully, especially from an agent shell such as Claude Code:
unset ELECTRON_RUN_AS_NODEfirst. Some agent shells, such as Claude Code, exportELECTRON_RUN_AS_NODE=1, which makes every Electron binary run as plain Node. When that happensrequire('electron').appisundefinedand every test crashes at SDK load (normalize.jscallingapp.getAppPath()) or times out. This is not a broken harness — it only affects shells where that variable is set.- Set
ELECTRON_VERSION. The runner throwsELECTRON_VERSION is not setotherwise. The SDK needs Electron 35 or higher, so use a version in that range whose binary is already cached (e.g.39.8.10). - Build and pack the SDK first. The test apps install
sentry-electron-v<version>.tgzfrom the repo root, andyarn e2edoes not create it. Runyarn build && yarn packafter each change tosrc. - Use
yarn e2e, not a barevitestinvocation.yarn e2eruns thepree2estep (set-version, cache cleanup) that the tests depend on. -tis a regex, so escape parentheses in test names, e.g.-t 'Browser Tracing \(Span streaming\)'.DEBUG=trueprints every received envelope as[Test Runner] Received event ..., which is the easiest way to build/verify assertions.
Example — run all span-streaming tests against Electron 39.8.10:
unset ELECTRON_RUN_AS_NODE
yarn build && yarn pack
DEBUG=true ELECTRON_VERSION=39.8.10 yarn e2e -t 'Span streaming'