Skip to content

docs: use queryByText in guide-disappearance.mdx#1532

Closed
davidjb wants to merge 1 commit intotesting-library:mainfrom
davidjb:patch-1
Closed

docs: use queryByText in guide-disappearance.mdx#1532
davidjb wants to merge 1 commit intotesting-library:mainfrom
davidjb:patch-1

Conversation

@davidjb
Copy link
Copy Markdown

@davidjb davidjb commented Apr 1, 2026

This adjusts the first example on this page to use the queryBy finder instead of getBy to avoid throwing in the query itself.

This gotcha gets explained a few times later in the doc (https://testing-library.com/docs/guide-disappearance#waiting-for-disappearance) but this is the first example you come to, and the use of getByText means the expect(...).toBeInTheDocument() will never be called.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 1, 2026

Deploy Preview for testing-library ready!

Name Link
🔨 Latest commit 84ea7e5
🔍 Latest deploy log https://app.netlify.com/projects/testing-library/deploys/69ccad300333da0008d77c44
😎 Deploy Preview https://deploy-preview-1532--testing-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@davidjb
Copy link
Copy Markdown
Author

davidjb commented Apr 2, 2026

Self-closing on account of the explanation at https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-presence-queries.md - the docs would benefit from distinguishing explicit choices on using getBy, assuming that applies here.

@davidjb davidjb closed this Apr 2, 2026
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.

1 participant