Closed as not planned
Description
Describe the bug
My test is broken on version 4.0.0-alpha.12
but it works correctly on version 3.5.1
.
It is throwing the following error when running it:
FAIL shared/component-library/Carousel/Carousel.test.tsx
Carousel
✕ renders properly (55 ms)
● Carousel › renders properly
TypeError: (0 , _computedWithAutoFillData.computedOffsetXValueWithAutoFillData) is not a function
19 | render(<Carousel data={data} renderItem={renderItem} width={200} />);
20 |
> 21 | jest.advanceTimersByTime(2000);
| ^
22 |
23 | screen.debug();
My test:
import React from 'react';
import { Text } from 'react-native';
import Carousel, { CarouselRenderItem } from 'react-native-reanimated-carousel';
import { render, screen } from '@testing-library/react-native';
const data = ['Slide 1', 'Slide 2', 'Slide 3'];
const renderItem: CarouselRenderItem<string> = ({ item }) => (
<Text>{item}</Text>
);
describe('Carousel', () => {
beforeEach(() => {
jest.useFakeTimers();
jest.clearAllMocks();
});
it('renders properly', async () => {
render(<Carousel data={data} renderItem={renderItem} width={200} />);
jest.advanceTimersByTime(2000);
screen.debug();
const card1 = await screen.findByText(data[0]);
expect(card1).toBeDefined();
});
});
To Reproduce
Steps to reproduce the behavior:
- Install the version
4.0.0-alpha.12
; - Run the test above;
- See error
Expected behavior
The carousel should render the slides in the DOM and the test should pass.
What I expect to see when I run screen.debug()
:
<View
style={
{
"flex": 1,
}
}
>
<View
collapsable={false}
forwardedRef={[Function anonymous]}
handlerTag={1}
handlerType="PanGestureHandler"
jestAnimatedStyle={
{
"value": {},
}
}
onGestureHandlerEvent={[Function anonymous]}
onTouchEnd={[Function anonymous]}
onTouchStart={[Function anonymous]}
style={
{
"flexDirection": "row",
"height": "100%",
"overflow": "hidden",
"width": 200,
}
}
>
<View
collapsable={false}
jestAnimatedStyle={
{
"value": {
"transform": [
{
"translateX": 0,
},
],
},
}
}
style={
{
"height": "100%",
"position": "absolute",
"transform": [
{
"translateX": 0,
},
],
"width": 200,
}
}
testID="__CAROUSEL_ITEM_0_READY__"
>
<Text>
Slide 1
</Text>
</View>
<View
collapsable={false}
jestAnimatedStyle={
{
"value": {
"transform": [
{
"translateX": 200,
},
],
},
}
}
style={
{
"height": "100%",
"position": "absolute",
"transform": [
{
"translateX": 200,
},
],
"width": 200,
}
}
testID="__CAROUSEL_ITEM_1_READY__"
>
<Text>
Slide 2
</Text>
</View>
<View
collapsable={false}
jestAnimatedStyle={
{
"value": {
"transform": [
{
"translateX": -200,
},
],
},
}
}
style={
{
"height": "100%",
"position": "absolute",
"transform": [
{
"translateX": -200,
},
],
"width": 200,
}
}
testID="__CAROUSEL_ITEM_2_READY__"
>
<Text>
Slide 3
</Text>
</View>
</View>
</View>
Versions:
- react: v18.2.0
- react-native: v0.71.14
- react-native-reanimated: v3.14.0
- react-native-reanimated-carousel: v4.0.0-alpha.12
- react-native-gesture-handler: v2.16.0
Smartphone (please complete the following information):
- Device: [e.g. iPhone6] N/A
- OS: [e.g. iOS8.1] N/A
- Browser [e.g. stock browser, safari] N/A
- Version [e.g. 22] N/A
- iTerm2: Build 3.5.3
Additional context
I know version 4.0.0
is still in Alpha, but I thought you wanted to know about this issue before the release.