我无法在现有的react-native
应用上进行测试设置。
我正在使用一个名为react-native-material-loading-button
的库,该库仅提供一个按钮,当您更新传入的属性时,该按钮可以显示微调框。
我的测试由于某种原因进入该行时仍然失败
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)
最重要的一点是引用components/MapCard/index.js
的最后一行,但是正在运行的测试是pages/Login/index.test.js
https://gist.github.com/Jordan4jc/f6656f7eb90d161b39f9fe7701d22dd1
里面有很多东西,我不知道这里是否有什么东西表明它是如何获取此文件的?
这是有问题的测试
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();
});