在本机基础组件上进行酶安装测试

时间:2019-08-29 17:33:47

标签: javascript typescript react-native enzyme native-base

我正在尝试使用酶固定剂来测试某些复合材料组件。但是我收到一条错误消息

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

LoginScreen将作为默认类导出,因此我导入类的方式是正确的。 然后,我测试了LoginScreen类中的每个组件,并且意识到测试仅在基于本机的组件上失败。但是我不确定原因,也没有文档说明这种情况。

以下五个组件的测试失败。

import { Form, Icon, Input, Item, Label } from "native-base";
import React from 'react';
import LoginScreen from "../../src/views/LoginScreen/index";
import { mount, render } from 'enzyme';
import {TesterUtils} from "../__utils__/Tester";
import {Provider} from "mobx-react/custom";
import {RootServiceInjector} from "../../src/services/injection";


describe("login function with mount", () => {
    it("try with mount", () => {
        const testerUtils = new TesterUtils();
        const rootService = testerUtils.getServiceRoot();
        const wrapper = mount(
            <Provider {...{[RootServiceInjector]: rootService}}>
                <LoginScreen/>
            </Provider>
        );
    });
});

还有其他人遇到过此问题并有解决方案吗? 非常感谢!

0 个答案:

没有答案