pptr-testing-library icon indicating copy to clipboard operation
pptr-testing-library copied to clipboard

offer puppeteer extend-expect methods

Open patrickhulce opened this issue 7 years ago • 2 comments

while technically not part of dom-testing-library it'd be nice to offer the same convenience expectations. Maybe this belongs in jest-puppeteer?

import 'dom-testing-library/extend-expect'

// <span data-testid="greetings">Hello World</span>
expect(queryByTestId(container, 'greetings')).toBeInTheDOM()
expect(queryByTestId(container, 'greetings')).not.toHaveTextContent('Bye bye')
// ...

patrickhulce avatar Jun 29 '18 22:06 patrickhulce

Any updates on this?

Btw. Meanwhile, what is the best way of asserting that an element is in the DOM without having the .toBeInTheDOM() function at hand?

crs1138 avatar Dec 03 '21 12:12 crs1138

Any updates on this?

Nope. Looking at this several years later, this does not seem very important IMO 😅 The text content handler would be nice but the first one doesn't seem to have any benefits over getByTestId unless there's something I'm missing...

what is the best way of asserting that an element is in the DOM without having the .toBeInTheDOM() function at hand?

await getByTestId(container, 'greetings') is my preferred pick for a nice error message with surrounding context.

patrickhulce avatar Dec 03 '21 16:12 patrickhulce