Skip to content

feat(jest): name the running test when the app crashes or disconnects - #204

Open
mrousavy wants to merge 1 commit into
callstackincubator:mainfrom
mrousavy:feat/report-running-test-on-crash
Open

mrousavy wants to merge 1 commit into
callstackincubator:mainfrom
mrousavy:feat/report-running-test-on-crash

Conversation

@mrousavy

Copy link
Copy Markdown
Contributor

What is this?

When the app crashes, the bridge disconnects, or the device stops responding while a test file is running, Harness fails the whole file with a message like "The app bridge disconnected during test execution." The message doesn't say which test was running. In a file with dozens of tests, finding the one that took the app down means splitting the file and rerunning until you've narrowed it down. In Nitro we split one file into 36 to find a single Hermes crash.

With this change the failure names the test that was running:

● Test suite failed to run

  The app bridge disconnected during test execution. This can happen if the app was killed, crashed, reloaded, or restarted while the test file was running.
  Running test: "TestObjectCpp › thisObject returns a HybridObject of the same type"

How does it work?

The device already sends test-started and test-finished events for every test, and executeRun forwards them to Jest. It now also keeps the last test that started and hasn't finished, and clears it when a new file starts. Tests run one at a time, so that's the test the app was in when it went away. If the file then fails with a runtime failure (native crash, runtime or bridge disconnect, startup stall, or device not responding), a Running test: line goes right under the first line of the failure message. The name is the ancestor titles and the test name joined with ›, the way Jest titles failures. beforeEach and afterEach run inside a test's started/finished window, so a crash there points at that test.

When no test was running, for example during startup, test collection, or a beforeAll/afterAll hook, the message stays as it is today. The host only knows what the device reported, so if the app dies before its test-started event reaches the host, the message also stays the same.

Why is this useful?

One run is enough to see which test crashed the app, locally or in CI, without splitting the file. That matters most for crashes that only happen on certain devices or in CI, where every rerun is slow. Projects that track this today with a plugin listening to test:started and the crash hooks (Nitro does, in margelo/nitro#1695) can drop it.

executeRun now keeps the test that started on the device but has not
finished yet, and clears it when a new file starts. When the file fails
with a runtime failure (native crash, runtime or bridge disconnect,
startup stall, device not responding), the failure message gets a
`Running test: "Suite › test"` line under its headline. Failures
outside a test keep their current message.
@vercel

vercel Bot commented Oct 15, 2026

Copy link
Copy Markdown

@mrousavy is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

mrousavy added a commit to margelo/nitro that referenced this pull request Oct 15, 2026
#1696)

Harness itself will name the test that was running when the app crashed
once callstackincubator/react-native-harness#204 is released, so the
plugin can be removed then.
mrousavy added a commit to margelo/react-native-nitro-modules that referenced this pull request Oct 15, 2026
…y (#1696)

Harness itself will name the test that was running when the app crashed
once callstackincubator/react-native-harness#204 is released, so the
plugin can be removed then.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant