internal: Capture extraneous console output in tests#3773
Conversation
|
|
Size Change: 0 B Total Size: 80.4 kB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3773 +/- ##
=======================================
Coverage 98.05% 98.05%
=======================================
Files 151 151
Lines 2832 2832
Branches 554 554
=======================================
Hits 2777 2777
Misses 11 11
Partials 44 44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Spy on console.error, console.warn, console.info, and console.log in
test files where expected output was leaking to stderr/stdout. Uses
jest.spyOn with mockImplementation in beforeAll/afterAll to suppress
noise while keeping assertions on console call counts intact.
Key changes:
- Add console spies to 28 test files across react, rest, and vue packages
- Wrap act() around async endpoint calls in testDispatchFetch (web)
- Scope 'reset promises' test into describe('unmount handling') with
dedicated console.info spy for post-unmount dispatch messages
- Fix AsyncBoundary test to use spyOn instead of direct console assignment
- Fix jest.config.js formatting (cosmetic)
Made-with: Cursor
4fc3432 to
4988ad2
Compare
Motivation
Test runs were noisy with console.error, console.warn, console.info, and console.log messages leaking to stderr/stdout. These messages (React
act()warnings, post-unmount dispatch info, InteractionManager deprecation warnings, etc.) are expected side effects of the code under test but were cluttering test output, making it harder to spot real issues.Solution
Add
jest.spyOn(console, ...)withmockImplementation(() => {})across 28 test files in react, rest, and vue packages. Spies are scoped tobeforeAll/afterAllto avoid timing issues with@testing-librarycleanup ordering.Key changes:
console.error(React act warnings, error boundaries),console.warn(RN InteractionManager deprecation),console.info(post-unmount dispatch messages),console.log(reset fetch logging)useSuspense.web.tsx: WrappedtestDispatchFetchendpoint calls inact(), scoped "reset promises" test intodescribe('unmount handling')with dedicatedconsole.infospyuseSuspense.native.tsx: Addedconsole.warn/console.errorspies, documented why nativetestDispatchFetchcan't await endpoint calls (nock doesn't intercept native fetch)AsyncBoundary.web.tsx: Replaced directconsole.error = jest.fn()assignment with properjest.spyOnpatternconsoleSpy.mock.calls.length, spies now usemockImplementationto suppress output while preserving call tracking, withmockRestore()in cleanupOpen questions
N/A
Made with Cursor
Note
Low Risk
Primarily test-only changes plus TypeScript declaration updates; low runtime risk, with minor chance of masking unexpected console output or slightly altering type inference for path params in the playground.
Overview
Reduces test noise by silencing expected console output across React/React Native/Vue/REST test suites via scoped
jest.spyOn(console, ...)mocks (with proper restore), and replaces a few ad-hocconsole.error = jest.fn()patterns.Tightens a couple of tests for correctness/stability (e.g., wrapping endpoint execution in
act()and scoping unmount-related cases), and updates the playground editor*.d.tsREST path-arg types to better handle*wildcards, optional}-terminated tokens, and array-valued params.Written by Cursor Bugbot for commit 4988ad2. This will update automatically on new commits. Configure here.