question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

testing react-native app with jest, undefined symbol: SSL_library_init

See original GitHub issue

Goals

I wanted to test my react native application with jest But i get this error


> proj@0.0.1 test /home/castix/proj
> jest

 FAIL  __tests__/index.android.js
  ● Test suite failed to run

    /home/castix/proj/node_modules/realm/compiled/node-v57_linux_x64/realm.node: undefined symbol: SSL_library_init

      at Runtime.requireModule (node_modules/jest-runtime/build/index.js:372:31)
      at Object.<anonymous> (node_modules/realm/lib/index.js:102:28)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.796s
Ran all test suites.
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
^C

undefined symbol: SSL_library_init Is there something I need to mock with jest or is it an issue with the linking of libssl The application seems to work fine, but I can’t set up unit tests

Code Sample

jest config in package.json

    "snapshotSerializers": [
      "enzyme-to-json/serializer"
    ],
    "preset": "react-native",
    "verbose": true,
    "transformIgnorePatterns": [
      "node_modules/(?!react-native|@shoutem/theme|@shoutem/animation|@shoutem/ui|pouchdb-react-native|pouchdb-adapter-asyncstorage|react-native-fetch-blob|realm)"
    ],
    "setupFiles": [
      "./jest_setup.js"
    ]
  }

jest_setup.js

import { NativeModules } from "react-native";

NativeModules.BlobModule = {
  ...NativeModules.BlobModule,
  addNetworkingHandler: jest.fn()
};

and __tests__/index.android.js

import React from 'react';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

import Index from '../index.android.js';

Version of Realm and Tooling

  • Realm JS SDK Version: 2.12.0
  • Jest: 23.3.0
  • Node or React Native: react native 55
  • Client OS & Version: ArchLinux 4.17.3-1-ARCH
  • Which debugger for React Native: None

The most similar issue I found is https://forum.realm.io/t/realm-studio-linux-doesnt-open/896 Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
CastixGitHubcommented, Jul 10, 2018

Thanks

I think I found a temporary fix: $ LD_PRELOAD=/usr/lib64/openssl-1.0/libcrypto.so:/usr/lib64/openssl-1.0/libssl.so npm test

0reactions
bmunkholmcommented, May 7, 2019

Closed due to no response.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing React Native Apps - Jest
At Facebook, we use Jest to test React Native applications. Get a deeper insight into testing a working React Native app example by...
Read more >
Constants are undefined while testing using Enzyme + React ...
Ran into a similar problem; my Jest test was failing with TypeError: Cannot read property 'manifest' of undefined at this line in one...
Read more >
Test Utilities - React
ReactTestUtils makes it easy to test React components in the testing framework of your choice. At Facebook we use Jest for painless JavaScript...
Read more >
React Navigation | React Native Testing Library - Open Source
This section deals with integrating @testing-library/react-native with react-navigation, using Jest.
Read more >
Testing - React Native
In this guide, we will cover different, automated ways to ensure your app works as expected, ranging from static analysis to end-to-end tests....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found