Commit 245d1c8
feat: Add test coverage for
## Summary
Adds missing test coverage for error handling paths in
`executeSafePromise` introduced by the browser compatibility refactor
(#3310).
## Changes
- **Node/Electron environment tests**: Verify `process.exit(1)` is
called on promise rejection and fatal errors are logged
- **Browser environment tests**: Verify errors are thrown with proper
error chaining via `cause` property
The environment detection behavior is implicitly verified by the Node
and browser test blocks, which mock or remove `process.exit` and verify
the appropriate code path is taken.
## Checklist before requesting a review
- [ ] Is this a breaking change? If it is, be clear in summary.
- [x] Read through code myself one more time.
- [x] Make sure any and all `TODO` comments left behind are meant to be
left in.
- [x] Has reasonable passing test coverage?
- [ ] Updated changelog if applicable.
- [ ] Updated documentation if applicable.
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/streamr-dev/network/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Expands test coverage for `executeSafePromise` to validate
error-handling in different runtimes.
>
> - Adds Node/Electron tests in
`packages/utils/test/executeSafePromise.test.ts` to assert
`process.exit(1)` is invoked on rejection and that exit is triggered
after fatal errors
> - Adds browser-environment tests by removing `process.exit` to assert
a thrown error with message `executeSafePromise: Assertion failure!` and
proper `cause` chaining
> - Retains success-path test to confirm resolved value handling
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ff0e81f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mondoreale <320066+mondoreale@users.noreply.github.com>executeSafePromise error handling paths (#3311)1 parent 98508fa commit 245d1c8
1 file changed
+75
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
12 | 87 | | |
0 commit comments