-
-
Notifications
You must be signed in to change notification settings - Fork 523
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
JS Bridge Error - Cannot read property SECURITY_LEVEL_ANY of undefined #192
Comments
Added a global jest setup and mocked the entire Native Module:
|
Ping @mandrigin. Not sure we want to fix this. |
This is breaking a production build for me. The dependency comes from @haskkor/react-native-pincode I am confused because it appears to have been fine before. |
It looks like it doesn't load native modules for some reason. But if it doesn't then the whole library is kind of useless. I probably need to learn more how exactly you are building the app. |
It is a react-native app. Thing is I have it all working fine on one branch with PINCode working fine and on another it is failing. Currently investigating yarn.lock but can't really see what the significant difference is between the two builds. I will post back here once we nail it. Anyy suggestions as to where we should be looking will be well received as, for now, its a puzzle! |
Thanks! |
the cause is here react-native-keychain/index.js Line 5 in 01755de
you need to mock the constants exported from the native module for your JS tests This does not explain though why builds suddenly stopped working for you. Are you sure you didn't upgrade? |
Were you able to mock?? I tried to mock the whole class as you described, but it's still throwing the |
@marciok Yes, but you need to include it in your jest setup file and in
jest-setup.js
|
Thanks @fpauer that worked a treat. Legend!! |
I was able to mock this, sufficiently, in my jest's before all, using the following code:
|
If I am getting this error merely when I import "import * as Keychain from 'react-native-keychain';" |
Hey following up here. I get this error when I import "import * as Keychain from 'react-native-keychain';" into a react-native file. Ran yarn and react-native-link successfully. Not using Jest or anything. Can someone let me know what I need to fix this? Thanks! @oblador @fpauer @mandrigin |
If you are getting it in a live app then you haven’t linked the module
natively.
react-native link react-native-keychain
Or else link manually by following RN docs on it.
…On Mon 4 Mar 2019 at 04:22, David Goldberg ***@***.***> wrote:
Hey following up here. I get this error when I import "import * as
Keychain from 'react-native-keychain';" into a react-native file. Ran yarn
and react-native-link successfully. Not using Jest or anything. Can someone
let me know what I need to fix this? Thanks! @oblador
<https://github.com/oblador> @fpauer <https://github.com/fpauer>
@mandrigin <https://github.com/mandrigin>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#192 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB1mZd7nYxFmqdBRmzbw7OYnmqDr6Kifks5vTC7ogaJpZM4a6LZP>
.
|
@brianfoody thanks I did successfully link via react-native link react-native-keychain before getting the error. I was able to manually link and the error went away. I'm unblocked thank you. In general I assume its best practice to use cocoa pods instead of dragging the workspace file into the Libraries folder manually and adding the .a module to Link Binary with Libraries correct? |
I try to avoid pods if I can and just use react native link. It’s not
always perfect though. The manual process does feel a bit wrong but at
least it’s easily fixed. When pods breaks stuff it’s always a nightmare for
me.
…On Mon 4 Mar 2019 at 11:07, David Goldberg ***@***.***> wrote:
@brianfoody <https://github.com/brianfoody> thanks I did successfully
link via react-native link react-native-keychain before getting the error.
I was able to manually link and the error went away. I'm unblocked thank
you.
In general I assume its best practice to use cocoa pods instead of
dragging the workspace file into the Libraries folder manually and adding
the .a module to Link Binary with Libraries correct?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#192 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB1mZeL8dpM023KLhZQiuseFgwCPFTrhks5vTI39gaJpZM4a6LZP>
.
|
Good to hear you are unblocked, I know the pain of getting blocked on these
things only too well.
…On Mon 4 Mar 2019 at 11:18, Brian Foody ***@***.***> wrote:
I try to avoid pods if I can and just use react native link. It’s not
always perfect though. The manual process does feel a bit wrong but at
least it’s easily fixed. When pods breaks stuff it’s always a nightmare for
me.
On Mon 4 Mar 2019 at 11:07, David Goldberg ***@***.***>
wrote:
> @brianfoody <https://github.com/brianfoody> thanks I did successfully
> link via react-native link react-native-keychain before getting the error.
> I was able to manually link and the error went away. I'm unblocked thank
> you.
>
> In general I assume its best practice to use cocoa pods instead of
> dragging the workspace file into the Libraries folder manually and adding
> the .a module to Link Binary with Libraries correct?
>
> —
> You are receiving this because you were mentioned.
>
>
> Reply to this email directly, view it on GitHub
> <#192 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AB1mZeL8dpM023KLhZQiuseFgwCPFTrhks5vTI39gaJpZM4a6LZP>
> .
>
|
As mentioned above, we are also exhibiting this issue when in a Jest context. It'd be awesome if that mock solution was in a file in this node module. Other libraries going through this:
If anybody wants to submit a PR, I recommend doing something like the above examples? |
I solved the
Unfortunately all other methods described here didn’t work. |
Thanks @brianfoody linking manually worked for me |
Though I agree with @fbartho that the end goal would be a functional mock that could be imported by developers for testing, I think a good no-effort stopgap would be to surface @fpauer's solution in the README, which is what several other packages also do to help out RN + Jest users. I created a quick PR to add a section with the instructions for how to mock and (hopefully) unbreak the build of anyone else affected by this. |
@genuinezack another approach to mock the whole package is: 1 - Create a folder in
In that way you dont need to define jest setup files |
Yup! However, the project I'm helping out with already had a setup file (for mocking local data & API endpoints) and didn't have a |
@fpauer I have the same code as you suggest but the test not working and indicates the following error: Using the current latest version of keychain: here is the code which I am using: Defining the type globally:
Then use it for all places like the following:
Having moke on setup file:
Mentioned on package json file too:
Please let me know whether I am making any mistakes... |
i reset the cache and some other stuff and closed the debug mode and it is working. I suppose this happens if you are working on more than one projects at a time in same machine |
I've just got the latest versions 3.1.0 and 3.1.1 and unit tests started to fail
● Test suite failed to run
The text was updated successfully, but these errors were encountered: