Add test suites to check Reanimated Babel plugin idempotency #4441
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.
Summary
For correct functioning of Reanimated idempotency of our Babel plugin is important. This PR adds a few unit tests for plugin's triggers in more-or-less complicated situations.
This obviously is not a confirmation of idempotency, that's arguably unachievable with simple unit tests. There is however some additional step that can be taken here.
In
plugin/
we have a development README with some simple chart of plugin's logic included. This chart could be expanded to contain more details about the results of code transformations thus lead to proof of idempotency. For example:How do we know this? It's simple: every explicit worklet will be transformed to a CallExpression. CallExpressions are not transformed within this scope, hence another run of plugin will not transform anything.
By saying scope I mean some limited transformation cases: plugin will not attempt explicit worklet transformation of already transformed explicit worklet. It will however try to transform a CallExpression if this CallExpression is for eg. named
useAnimatedStyle
and explicit worklets are transformed to CallExpressions. This transformation will probably still be idempotent though.Therefore, the next step after checking idempotency within those scopes would be to analyze the situations when the result of a certain transformation crosses a boundary of two scopes.
Creation of a chart that would contain all of necessary information for the idempotency proof seems to be quite a lot of work but is definitely doable and would certainly be much more informative than some 'random' unit tests. The only question is if we actually need it in such detail.
Test plan
CI tests are sufficient.