React-native-testing-library: jest-dom extend-expect

Created on 21 Dec 2018  Â·  7Comments  Â·  Source: callstack/react-native-testing-library

Hi,
love this library!
just wondering if your planning to get the jest-dom/extend-expect functions converted to Native?
I have a bunch of tests where I introspect text results ...
I can do a getByText but in some cases I need to get all text for a parent Text component that contains a bunch of child Text components.
Thanks for your help,
/Stephen.

enhancement good first issue

Most helpful comment

Use @testing-library/jest-native. Then import like this
import '@testing-library/jest-native/extend-expect';

All 7 comments

Sounds like cool thing to have. Here's a list of all matchers: https://github.com/gnapse/jest-dom#custom-matchers

Does anybody feel like implementing this for native? :)

I started something here: https://github.com/brooksbecton/react-native-jest-expect-extensions
as a proof of concept with a .toBeDisabled extension

Would this be part of 'react-native-testing-library' or would it be a separate repo?

I think @Esemesek started something around that as well, so feel free to collaborate :). I'd prefer to have the matchers live in this repository.

It's important to make them output high-quality error messages – I encourage you to take a look at Jest matchers recently getting improved by @pedrottimark, e.g. https://github.com/facebook/jest/blob/7e4e170023b29f1e78dbe757b12b291443a53c6a/packages/expect/src/matchers.ts#L200-L221.

I've got a few extensions going. Were ya'll wanting all of them in before I PR?

Also, where would you want these to go in the project?

I'd create a directory src/custom-matchers and store them there.

Use @testing-library/jest-native. Then import like this
import '@testing-library/jest-native/extend-expect';

Closing in favor of #298. I see some of you already use @testing-library/jest-native so I hope it will only be a matter of documenting it and providing some tests that we're compatible :)

Was this page helpful?
0 / 5 - 0 ratings