-
Notifications
You must be signed in to change notification settings - Fork 576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add @testing-library/react-native #5197
Conversation
4a6a7e4
to
45dcd3f
Compare
Looking forward to this @gkartalis 🙌 |
Co-authored-by: Pavlos Vinieratos <pvinis@gmail.com>
@@ -13,18 +13,18 @@ import { VanityURLPossibleRedirect } from "../VanityURLPossibleRedirect" | |||
|
|||
beforeEach(() => { | |||
__globalStoreTestUtils__?.setProductionMode() | |||
fetchMock.mockReset() | |||
fetchMock.resetMocks() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Know this one well 😄
@@ -60,10 +59,11 @@ describe("Sale", () => { | |||
) | |||
|
|||
expect(navigate).toHaveBeenCalledTimes(0) | |||
jest.advanceTimersByTime(1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
jest.mock("lib/relay/createEnvironment", () => ({ | ||
defaultEnvironment: require("relay-test-utils").createMockEnvironment(), | ||
})) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency feels nice :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(just tagging @pepopowitz so he can check the solution!)
it("Loads OrderHistoryQueryRender with PageWithSimpleHeader", () => { | ||
const tree = renderWithWrappers(<OrderDetailsQueryRender orderID="21856921-fa90-4a36-a17e-dd52870952d2" />) | ||
expect(tree.root.findAllByType(PageWithSimpleHeader)).toHaveLength(1) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarification, this test is removed because it tests the exact same thing as the test above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pvinis only one thing that I didn't finish yet (maybe we can add a ticket for that) is changing the way that we are mocking fetch inside AuthModel-tests.ts cause the tests where too many and spent a lot of time without getting anywhere. Happy to write the ticket! Is it okay to merge? |
I think we should merge this, yes! It would be great if you could make the ticket, yes, thank you! That ticket should probably apply to https://github.com/artsy/eigen/pull/5208/files#diff-6ea405af9cca72603df862425acd31b1762cf1f94a9247adde1f91119b89f302R14-R21 too, so I would make it to that we change the "old" way of fetch mocking to the "new", and point out a couple of files that use the old still, and give some code that whoever picks the ticket can "search in project" and find all the places. Thanks again for your work on this! Merge whenever you like. |
* deps: add rn-testing-library dependencies * chore: setup rn-testing-library * feat: add renderWithWrappersTL * fix: changed rntl version * chore: removed test that doesn't add value * fix: removed unused import * chore: testing out stuff * chore: remove unused import * fix: fixed timer problems * spec: moved relay createEnv mock to setupJest * chore: cleanup * fix: refactor fetchmock and added helper Co-authored-by: Pavlos Vinieratos <pvinis@gmail.com> * chore: fix url * fix: attempt to fix ci failing test * fix: fetch await problem ci fix * chore: use jest-fetch-mock for mocking fetch Co-authored-by: Pavlos Vinieratos <pvinis@gmail.com>
The type of this PR is: Enhancement
This PR resolves []
Description
Another thing that is worth mentioning here is that the version is one minor release behind the latest cause of this issue fixed in this PR but not yet released.
ProblemsThe problem at the moment is that 4 tests are failing more specifically:OrderDetails-tests.tsxRegistrationFlow-tests.tsxMyBids-tests.tsxConsignments/tests/index-tests.tsx~~Reason: ~~
Failed: "TypeError: Cannot read property '_responseForQueryIDWithVariables' of undefined"
Failed: "TypeError: Cannot read property '_setResponseForQueryIDWithVariables' of undefined"
These two come from the following:Artsy/eigen/src/lib/NativeModules/GraphQLQueryCache.ts
Artsy/eigen/emission/Pod/Classes/GraphQL/ARGraphQLQueryCache.m
The above where solved when added these lines to mock
createEnvironment
to setupJest.ts.PR Checklist (tick all before merging)
Changelog updates
Changelog updates
Cross-platform user-facing changes
iOS user-facing changes
Android user-facing changes
Dev changes