Repository navigation
Conversation
Since View.prototype took the native methods, the jest-compat setup ends by requiring react-native and its NativeComponentRegistry through Node. Under the native engine the require hooks compile them, and under the mock engine the stand-in answers. With jestMockTransform() and the setup but no reactNative(), a project that uses the layer for the Jest API alone, nothing compiles them: Node parsed React Native's Flow source and every test file failed at startup with "SyntaxError: Unexpected token 'typeof'". 0.14 ran such a project. The setup now fills View.prototype only when projectContext() is set. Both engines' reactNative() write the project context, and nothing else does, so it tells reliably whether an engine is configured. Chosen over catching a failed load, which would also hide a real load error under an engine and still parse React Native's source on every file to find out. Under either engine nothing changes. tests-native/vitest.jest-compat-no-engine.config.mts runs the layer with no engine, in its own test:native step.
tests/fixture-mocks-scope.test.ts reads every tests-native config for jestMockTransform calls without a mock scope; the comment's mention of the call counted as one.
This branch has not been deployed
This file contains hidden or 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
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.
Since 0.15, a project that uses the jest-compat layer without an engine (
jestMockTransform()and the setup, noreactNative(), the way a react-native-web suite uses it for the Jest API) fails every test file at startup:The setup now requires
react-nativethrough Node to put the native methods onView.prototype. Without an engine nothing compiles React Native's Flow source, so Node chokes on it. 0.14 ran such a project.The fix skips that step when no engine is configured, which the project context tells; under either engine nothing changes. A new
test:nativestep runs the layer without an engine and fails on main with the error above.