-
Notifications
You must be signed in to change notification settings - Fork 577
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
[WIP]feat: add react native testing library #5132
Conversation
@@ -40,7 +41,7 @@ describe(ArtsyReactWebViewPage, () => { | |||
it("shares the correct URL", () => { | |||
const tree = render({ showShareButton: true }) | |||
tree.root.findByType(FancyModalHeader).props.onRightButtonPress() | |||
setTimeout(() => expect(jest.fn()).toHaveBeenCalledWith()) | |||
waitFor(() => expect(jest.fn()).toHaveBeenCalledTimes(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.
So here when adding @testing-library/react-native setTimeouts like this were breaking. I am not sure if it is the BEST approach to use waitFor from @testing-library/react-native in tests that are not written with this library.
What do you think?
beforeAll(() => { | ||
jest.useFakeTimers() | ||
}) | ||
afterAll(() => { | ||
jest.useRealTimers() | ||
}) |
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.
Removed the timers since with waitFor
we don't actually need them.
src/lib/tests/renderWithWrappers.tsx
Outdated
import { ReactElement } from "simple-markdown" | ||
|
||
export const Wrappers: React.FC = ({ children }) => { | ||
return ( | ||
// <RelayEnvironmentProvider environment={defaultEnvironment}> |
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.
Do we actually want this here? 🤔
The type of this PR is: Enhancement
This PR resolves []
@pvinis
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