0

I am writing test cases for ImageBackground and Image component in React native but the test cases is getting failed as I am using local assets. It is unable to fetch the location of the assets folder I guess. Can someone help me out with this issue?

 test('renders Background image', () => {
        const { getByTestId } = render(LandingScreen);
        expect(getByTestId('logo').toBeInTheDocument);
    })


    test('Logo must have src = "/logo.svg" and alt = "Logo"', () => {
        render(LandingPage);
        const logo = screen.getByRole('logo');
        expect(logo).toHaveAttribute('source', '../../../assets/logo.png');
    });

    it(" Product introduction check background Image present or not", () => {
      const logoImg = LandingScreen.root.findByProps({
        testID: "logo",
      }).props;
      expect(logoImg).toBeDefined();
    });
    it('should display a local image when given a valid image file path', () => {

        // Render the Image component with the provided image file
        const imageComponent = shallow(<Image source={require("../../assets/authBg.png")} />);
        expect(imageComponent.find('logo').prop('src')).toEqual(logo);
    })

I have tried these code for test cases but getting error this kind of error below are attached Screenshots [enter image description here](https://i.stack.imgur.com/UX1mg.png)

0 Answers0