Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react testing library getBy image

it('uses correct src', async () => {
    const { getByAltText } = await render(<MyComponent />);

    const image = getByAltText('the_alt_text');

    expect(image.src).toContain('the_url');
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #testing #library #getBy #image
ADD COMMENT
Topic
Name
6+1 =