Jest React Native,文本未定义

时间:2018-09-06 13:47:47

标签: react-native jestjs enzyme

我对我的组件进行了非常基本的测试:

import React from "react";
import { mount, shallow } from "enzyme";
import AgendaItem from "./AgendaItem";
import renderer from "react-test-renderer";

describe("<AgendaItem />", () => {
    it("it should render 1 view component", () => {
        const props = {
            item: {
                title: "test title"
            }
        };

        const wrapper = shallow(<AgendaItem {...props} />);
        expect(wrapper.find(View)).to.have.length(1);
    });

    it("it should render 5 text components", () => {
        const props = {
            item: {
                title: "test title",
                venue: "test venue",
                organiser: "test organiser",
                startTime: "8-00",
                description: "<p>test description</p>"
            }
        };
        const wrapper = shallow(<AgendaItem {...props} />);
        expect(wrapper.find(Text)).to.have.length(5);
    });
   });

Package.json:

  "jest": {
    "preset": "react-native",
    "setupTestFrameworkScriptFile": "<rootDir>/test-setup.js"
  }

如何在测试中寻找Text组件?

0 个答案:

没有答案