Javascript 在使用Anzyme和Jest的反应性测试中未检测到可触摸不透明度

Javascript 在使用Anzyme和Jest的反应性测试中未检测到可触摸不透明度,javascript,reactjs,react-native,jestjs,Javascript,Reactjs,React Native,Jestjs,我的测试失败了,因为它在测试时没有找到TouchableOpacity。我做错了什么? 下面是测试结果、组件文件、测试文件 结果 expect(已接收)。toHaveLength(预期) src/component/button.js import React,{PropTypes}来自“React”; 从“react native”导入{TouchableOpacity,Text}; 常量按钮=道具=>{ {props.label} ; }; Button.displayName=“Butt

我的测试失败了,因为它在测试时没有找到TouchableOpacity。我做错了什么? 下面是测试结果、组件文件、测试文件

结果 expect(已接收)。toHaveLength(预期)

src/component/button.js

import React,{PropTypes}来自“React”;
从“react native”导入{TouchableOpacity,Text};
常量按钮=道具=>{
{props.label}
;
};
Button.displayName=“Button”; 导出默认按钮

测试/button.test.js

/**
*@jest-environment-jsdom
*/
//button.js
从“React”导入React;
从“酶”中导入{shall};
从“./src/components/Button”导入按钮;
描述(“呈现”,()=>{
让包装纸;
在每个之前(()=>{
包装器=浅();
});
//我们可以有可点击的对象吗
它(“应该呈现”,()=>{
expect(wrapper.find(“TouchableOpacity”).toHaveLength(1);
});=
});
Expected length: 1
Received length: 0
Received object: {}
import React, { PropTypes } from "react";
import { TouchableOpacity, Text } from "react-native";

const Button = props => {
  <TouchableOpacity>
    <Text>{props.label}</Text>
  </TouchableOpacity>;
};
/**
 * @jest-environment jsdom
 */
// button.js
import React from "react";
import { shallow } from "enzyme";
import Button from "../src/components/Button";

describe("Rendering", () => {
  let wrapper;
  beforeEach(() => {
    wrapper = shallow(<Button label="Submit" />);
  });
  // Can we have clickable object
  it("Should render a <TouchableOpacity />", () => {
    expect(wrapper.find("TouchableOpacity")).toHaveLength(1);
  });=
});