-
-
Notifications
You must be signed in to change notification settings - Fork 86
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: iOS unit tests #366
Merged
Merged
feat: iOS unit tests #366
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
📊 Package size report
|
kirillzyusko
force-pushed
the
feat/ios-unit-tests
branch
from
March 25, 2024 07:51
2d56f72
to
36c9ca4
Compare
kirillzyusko
force-pushed
the
feat/ios-unit-tests
branch
from
March 29, 2024 08:42
5f4c76a
to
248c286
Compare
…be available on GH)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
Added native unit tests on iOS.
💡 Motivation and Context
Where to write unit tests?
The problem with current integration of unit-tests on iOS is the fact that we depends on
react
dependency heavily which is available inexample
orFabricExample
projects.Of course I didn't want to duplicate tests (and there is no clear option on how to add them for
KeyboardController.xcodeproj
i. e. root) so I decided to create a new "HelloWorld" project and link files that I want to test.Fortunately current codebase is designed quite well (thanks for supporting both architectures 😀), so I have a separated business-logic (keyboard frame tracking etc.) and consumers (react views/bridge bindings).
So I didn't make any modifications to the source code. The only one "suspicious" thing is adding extension for
reactTag
property (I rely on it in Extensions file and Extension file needs to be linked sinceViewHierarchyNavigator
usesUIResponder.current
extension).Unit tests approach
I decided to test everything as unit tests. Of course some of methods, such as
becomeFirstResponder
doesn't work (actually they work, but there is no way to check that method has been called as we can do in jest - and by default iOS doesn't provide any mocks).So I've created
TestableTextField
/TestableTextView
and for hierarchy creation used these classes.Some of corresponding Android tests can not be ported to iOS:
But overall I'm happy to have at least something to have a better protection over accident changes that can break the library code.
CI integration
Also I added a job on CI to run these tests continuously.
📢 Changelog
CI
iOS
KeyboardControllerNative
project;KeyboardControllerNative
from Pods (to prevent compilation errors);JS
KeyboardControllerNative
from being published tonpm
;🤔 How Has This Been Tested?
Tested locally and on CI.
📝 Checklist