lundi 11 février 2019

Test throwing reference error on a third party module

I'm having trouble getting testing setup on an existing react-native app we have.

I am using a library called react-native-material-loading-button which just gives a button that can show a spinner when you update a passed in property.

My test keeps failing when it gets to this line for some reason saying

 ReferenceError: styles is not defined

      16 | import PinInput from "../PinInput";
      17 | import { formatNumber } from "libphonenumber-js";
    > 18 | import LoadingButton from 'react-native-material-loading-button';
         |                                                                ^
      19 | import { checkPin } from "../../actions/authentication";
      20 | import { openSnackBar } from "../../actions/snack-bar";
      21 | import distance from '../../lib/distance';

      at Object.<anonymous> (node_modules/react-native-material-loading-button/styles.js:3:8)
      at Object.<anonymous> (node_modules/react-native-material-loading-button/index.js:5:38)
      at Object.<anonymous> (components/MapCard/index.js:18:64)

The kicker is that last line which references components/MapCard/index.js but the test that this is running is pages/Login/index.test.js

https://gist.github.com/Jordan4jc/f6656f7eb90d161b39f9fe7701d22dd1

There is a lot in there and I don't know if anything here would indicate how it's getting this file instead?

Here is the test in question

import 'react-native';
import React from 'react';
import {Login} from './index';
import { mount } from 'enzyme';


it('renders correctly', () => {
  const wrapper = mount(
    <Login />
  );
  expect(wrapper).toMatchSnapshot();
});

Aucun commentaire:

Enregistrer un commentaire