Skip to content

Incorrect props snapshot rendering #1759

Closed

Description

@qdanik

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

Activity

  1. mdjastrzebski commented on Apr 29, 2025

    @mdjastrzebski
    Member

    @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).

  2. qdanik commented on Apr 30, 2025

    @qdanik
    Author

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions