Skip to content

How to test react-native-collapsible/Accordion using testing-libray/react-native? #467

@Shail-Patel-1

Description

@Shail-Patel-1
 const { getByTestId } = testingHelpers.renderWithProviders(
      <ProductDetailScreen {...testProps} />,
      {
        preloadedState: preloadedState,
      }
    );
    const productSpecificationsTitleView = getByTestId(
      TestIds.PRODUCT_DETAIL.PRODUCT_SPECIFICATION_TITLE
    );

    expect(productSpecificationsTitleView).toBeDefined();

    await act(async () => {
      await fireEvent.press(productSpecificationsTitleView);
    });

    const productSpecificationsContentView = getByTestId(
      TestIds.PRODUCT_DETAIL.PRODUCT_SPECIFICATION_CONTENT
    );

    expect(productSpecificationsContentView).toBeDefined();
  });

Whether or not i press the title the content is still present in the dom

Used & tested:

toBeDefined
toBeOnScreen
toBeNull
toBeVisible

but above all fails
i used queryByTestId, getByTestId, queryByText

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions