Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How can I exclude a library from a Jest unit test?

$
0
0

I've added PendoSDK to my React Native app. App is using TypeScript and React Navigation. Although the app is working, after adding PendoSDK, it is failing most of my Jest unit tests. Here is an example of a simple test that is failing and associated error:

import React from 'react';import { render } from 'jest-utils';import { NumberData } from './NumberData';describe('NumberData', () => {  const component = <NumberData value={9} />;  it('should render without errors', () => {    expect(render(component)).toBeTruthy();  });  it('should render NumberData correctly', () => {    const { getByText } = render(component);    expect(getByText('09')).toBeTruthy();  });});

This test is failing with the error:

FAIL  src/components/NumberData/NumberData.test.tsx● Test suite failed to run    Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.      at invariant (node_modules/invariant/invariant.js:40:15)      at new NativeEventEmitter (node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js:44:7)      at Object.<anonymous> (node_modules/rn-pendo-sdk/lib/pendoRNN.js:1:766)      at Object.<anonymous> (node_modules/rn-pendo-sdk/lib/pendoAPI.js:1:723)

Prior to adding PendoSDK all of these tests were passing but now most of them are failing.

What should I do to correctly setup Jest for PendoSDK or is there a way to exclude PendoSDK from Jest test?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>