Skip to content

Conversation

@spencer-lochne
Copy link
Collaborator

No description provided.

</MemoryRouter>
);

const logo = screen.getByTestId('header-logo');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we test the src attribute if the image is imported?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how i tested it :

expect(
screen.getByTestId('header-logo')
).toHaveAttribute('src', '/src/assets/images/logo-white.png');

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just give alt attribute to the imported image, then use getByAltText or getByRole on the test

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants