Skip to content

Incorrect props snapshot rendering #1759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
qdanik opened this issue Apr 14, 2025 · 2 comments
Closed

Incorrect props snapshot rendering #1759

qdanik opened this issue Apr 14, 2025 · 2 comments

Comments

@qdanik
Copy link

qdanik commented Apr 14, 2025

Describe the bug

Incorrect snapshot rendering of props components.
P.S. it can be an issue of react-test-renderer

Code Example:

<ScrollView
  testID="scroll-view"
  refreshControl={
    <RefreshControl refreshing={refreshing} onRefresh={callback} />
  }
>
 <SomeScrollViewData />
</ScrollView>

Expected behavior

I want to see like a structured JSX component in snapshot output.

Example:

<RCTScrollView
    onScroll={[Function]}
    refreshControl={
      <RefreshControlMock
        onRefresh={[Function]}
        refreshing={false}
      />
    }
    testID="scroll-view"
  >
    <RCTRefreshControl />
    <SomeScrollViewData />
</RCTScrollView>

Steps to Reproduce

Setup empty project with listed dependencies and render example (provided below) using output toJSON method from the render(). To avoid RangeError: Invalid string length error during testing please setup snapshotFormat: { maxDepth: 10 } in jest.config.js, probably this is also an issue.

Screenshots

Image

Versions

npmPackages:
@testing-library/react-native: 13.1.1 => 13.1.1
jest: 29.7.0 => 29.7.0
react: 19.0.0 => 19.0.0
react-native: 0.78.2 => 0.78.2
react-test-renderer: 19.0.0 => 19.0.0

@mdjastrzebski
Copy link
Member

mdjastrzebski commented Apr 29, 2025

@qdanik This is an issue with pretty-format vs React 19. Take a look at this article. Basically you need to set version resolution react-is package to match your react version (19.0.0).

@qdanik
Copy link
Author

qdanik commented Apr 30, 2025

Thanks, @mdjastrzebski. The article provided exactly what I needed.

@qdanik qdanik closed this as completed Apr 30, 2025
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

No branches or pull requests

2 participants