From 8c6a89bcfd923aaea0c013bd24f542913ab584e3 Mon Sep 17 00:00:00 2001 From: Caspian Zhao Date: Mon, 30 Mar 2026 10:25:40 +0800 Subject: [PATCH 1/2] test: add issue #862 item rendering regression --- src/components/Carousel.issue-862.test.tsx | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/components/Carousel.issue-862.test.tsx diff --git a/src/components/Carousel.issue-862.test.tsx b/src/components/Carousel.issue-862.test.tsx new file mode 100644 index 00000000..2fffe2dd --- /dev/null +++ b/src/components/Carousel.issue-862.test.tsx @@ -0,0 +1,53 @@ +import React from "react"; +import { Text } from "react-native"; +import renderer, { act } from "react-test-renderer"; + +import Carousel from "./Carousel"; + +{ + const cfg = (global as any).__reanimatedLoggerConfig as + | { logFunction: (data: { level: number; message: string }) => void } + | undefined; + if (cfg) { + const originalLog = cfg.logFunction; + cfg.logFunction = (data) => { + if (data.message.includes("measure() cannot be used with Jest")) return; + originalLog(data); + }; + } +} + +describe("issue #862 carousel items render in tests", () => { + it("renders carousel items and text nodes, not only the wrapper", async () => { + const data = ["A", "B", "C"]; + let tree!: renderer.ReactTestRenderer; + + await act(async () => { + tree = renderer.create( + ( + {`Slide ${index}: ${item}`} + )} + /> + ); + await Promise.resolve(); + }); + + expect(tree.root.findAllByProps({ testID: "issue-862-carousel" }).length).toBeGreaterThan(0); + + for (const [index, item] of data.entries()) { + expect(tree.root.findAllByProps({ testID: `issue-862-item-${item}` }).length).toBeGreaterThan(0); + expect( + tree.root.findAllByType(Text).some((node) => node.props.children === `Slide ${index}: ${item}`) + ).toBe(true); + } + + await act(async () => { + tree.unmount(); + await Promise.resolve(); + }); + }); +}); From 11745c952a182a3cfc96a869069aa59273afb4d7 Mon Sep 17 00:00:00 2001 From: Caspian Zhao Date: Mon, 30 Mar 2026 10:26:12 +0800 Subject: [PATCH 2/2] chore: format issue #862 regression test --- src/components/Carousel.issue-862.test.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Carousel.issue-862.test.tsx b/src/components/Carousel.issue-862.test.tsx index 2fffe2dd..eed5f414 100644 --- a/src/components/Carousel.issue-862.test.tsx +++ b/src/components/Carousel.issue-862.test.tsx @@ -39,9 +39,13 @@ describe("issue #862 carousel items render in tests", () => { expect(tree.root.findAllByProps({ testID: "issue-862-carousel" }).length).toBeGreaterThan(0); for (const [index, item] of data.entries()) { - expect(tree.root.findAllByProps({ testID: `issue-862-item-${item}` }).length).toBeGreaterThan(0); + expect(tree.root.findAllByProps({ testID: `issue-862-item-${item}` }).length).toBeGreaterThan( + 0 + ); expect( - tree.root.findAllByType(Text).some((node) => node.props.children === `Slide ${index}: ${item}`) + tree.root + .findAllByType(Text) + .some((node) => node.props.children === `Slide ${index}: ${item}`) ).toBe(true); }