From a8611a4abb98848b654beb2421060c84170619e6 Mon Sep 17 00:00:00 2001 From: Brandon Johnson Date: Wed, 22 May 2019 11:09:51 -0600 Subject: [PATCH 1/2] Fix `getByAltText` examples Fixes #116 --- docs/dom-testing-library/api-queries.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/dom-testing-library/api-queries.md b/docs/dom-testing-library/api-queries.md index 6aa4da0cd..e3993076e 100644 --- a/docs/dom-testing-library/api-queries.md +++ b/docs/dom-testing-library/api-queries.md @@ -308,7 +308,7 @@ as it's deprecated). import { getByAltText } from 'dom-testing-library' const container = document.body -const incrediblesPosterImg = getByAltText(container, /incredibles.*png$/i) +const incrediblesPosterImg = getByAltText(container, 'Incredibles 2 Poster') ``` @@ -317,13 +317,13 @@ const incrediblesPosterImg = getByAltText(container, /incredibles.*png$/i) import { render } from 'react-testing-library' const { getByAltText } = render() -const incrediblesPosterImg = getByAltText(/incredibles.*png$/i) +const incrediblesPosterImg = getByAltText('Incredibles 2 Poster') ``` ```js -cy.getByAltText(/incredibles.*png$/i).should('exist') +cy.getByAltText('Incredibles 2 Poster').should('exist') ``` From 06043b21484fe2d0969555ff35db7024214334f6 Mon Sep 17 00:00:00 2001 From: Brandon Johnson Date: Wed, 22 May 2019 12:01:56 -0600 Subject: [PATCH 2/2] Use regular expression for `getByAltText` example --- docs/dom-testing-library/api-queries.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/dom-testing-library/api-queries.md b/docs/dom-testing-library/api-queries.md index e3993076e..024565a6f 100644 --- a/docs/dom-testing-library/api-queries.md +++ b/docs/dom-testing-library/api-queries.md @@ -308,7 +308,7 @@ as it's deprecated). import { getByAltText } from 'dom-testing-library' const container = document.body -const incrediblesPosterImg = getByAltText(container, 'Incredibles 2 Poster') +const incrediblesPosterImg = getByAltText(container, /incredibles.*? poster/i) ``` @@ -317,13 +317,13 @@ const incrediblesPosterImg = getByAltText(container, 'Incredibles 2 Poster') import { render } from 'react-testing-library' const { getByAltText } = render() -const incrediblesPosterImg = getByAltText('Incredibles 2 Poster') +const incrediblesPosterImg = getByAltText(/incredibles.*? poster/i) ``` ```js -cy.getByAltText('Incredibles 2 Poster').should('exist') +cy.getByAltText(/incredibles.*? poster/i).should('exist') ```