-
Notifications
You must be signed in to change notification settings - Fork 18
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: Implement jest mocks for react-native. #535
base: main
Are you sure you want to change the base?
feat: Implement jest mocks for react-native. #535
Conversation
…so added 6 levels to workspace root of metro.config.js
… find-yarn-workspace-root and index.js to jest example to fix monorepo issues, added @launchdarkly/jest/react-native to App.tsx and welcome.tsx
…nvironment in react-native jest to jsdom
import { mockFlags, mockUseLDClient } from '@launchdarkly/jest/react-native'; | ||
|
||
export default function Welcome() { | ||
const flagValue = mockFlags({ 'dev-test-flag': true }); |
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.
I think that we probably want the example to appear like a normal react-native application using our SDK, then have tests that use a component from that application, but with a mock?
Similar to the example tests in the existing mocks project: https://github.com/launchdarkly/jest-launchdarkly-mock
…re like a normal react app that just mocks flags
… react app that just mocks flags
…to de-mock it after a conversation with Ryan.
8b05e27
to
4dc3bf2
Compare
…s work properly using welcome.tsx
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.
This looks good.
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
}); |
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.
Please add a newline to the end of this file.
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.
packages/tooling/jest/package.json
Outdated
"rimraf": "^5.0.1", | ||
"ts-jest": "^29.1.0", | ||
"typedoc": "0.25.0", | ||
"typescript": "5.1.6" | ||
}, | ||
"dependencies": { | ||
"@launchdarkly/react-native-client-sdk": "workspace:^", |
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.
I think we need the version from the package here. Otherwise funky things will happen when this is published.
…e not being used and were causing an issue. Also added addHook.
Requirements
Related issues
Provide links to any issues in this repository or elsewhere relating to this pull request.
Describe the solution you've provided
Provide a clear and concise description of what you expect to happen.
Describe alternatives you've considered
Provide a clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context about the pull request here.