jest-puppeteer icon indicating copy to clipboard operation
jest-puppeteer copied to clipboard

Use native Jest matchers

Open gregberge opened this issue 6 years ago • 5 comments

Jest supports asynchronous matchers and asymmetric matchers, two required things to port expect-puppeteer matchers into Jest matchers. Some problems still persist:

Some matchers are returning an element like toMatchElement()

A matcher should not return anything, yes. But it is very convenient to assert that something is in the page and get the element matched in the page. I think we probably need to rethink this part. I am open to propositions.

Some matchers are already used by Jest like toMatch

I think it is not a big problem, we can change the name. Also open to propositions.

gregberge avatar Aug 16 '18 09:08 gregberge

A matcher should not return anything, yes. But it is very convenient to assert that something is in the page and get the element matched in the page. I think we probably need to rethink this part. I am open to propositions.

Perhaps allow matchers to receive element refs instead of selectors? That way they're simply doing assertions.

// Edited because the original idea was silly.

srounce avatar Aug 30 '18 14:08 srounce

Thanks for your suggestion but I am sorry didn't get it, can you show me an example of code?

gregberge avatar Aug 30 '18 23:08 gregberge

👍 on the idea of allowing matchers to receive element refs instead of selectors. It would be nice to be able to do:

await expect(page).toClick($btn)

Where $btn is already an element handle.

akahn87 avatar Sep 06 '18 23:09 akahn87

@gregberge so is this essentially a wontfix?

swissspidy avatar Feb 03 '23 23:02 swissspidy

Sorry it was a mistake.

gregberge avatar Feb 04 '23 06:02 gregberge