-
Notifications
You must be signed in to change notification settings - Fork 583
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
Importing Realm breaks React Native jest tests #313
Comments
Working on it: jestjs/jest#779 |
Sorry that this is happening. I wasn't aware of some of the setup steps in react-native. I don't think |
Published jest 0.9.1 and babel-jest 9.0.2 which should resolve this. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Importing Realm into a React Native project breaks existing jest tests. This is probably partially related to #262, but the error in question is a decidedly opaque syntax error, vs. anything going on at runtime. I.e. I can't even run tests that mock Realm out.
Repro steps
git clone https://github.com/jwhitley/ReactNativeTesting
cd ReactNativeTesting
npm install
npm test
git checkout test-with-realm
npm install
(to installrealm
)npm test
Actual results
If the
realm
npm package is anywhere in the import chain in the tests, the following syntax error occurs:Expected results
Tests pass as before importing Realm. While the ability to run full integration tests under node would be the endgame, I'd be overjoyed to just have unit tests with Realm mocked out actually run.
Notes
The
test-with-realm
branch has just two changes:realm
npm package.import Realm from 'realm'
to the trivialsum.js
module being tested.This was motivated by adding Realm to a new RN project our company has started building, and watching the tests blow up with the above error.
The sample repo uses the about-to-be standard setup for jest testing with React Native. See discussion at facebook/react-native#6315. Of particular note is
babel-plugin-react-native
, which extracts the RN babel configuration into a first-class plugin, usable by other workflows than the RN packager.The text was updated successfully, but these errors were encountered: