面对TypeError:在测试React应用程序时,Expect(...)。toBeString不是函数

时间:2019-09-22 11:02:49

标签: reactjs jestjs enzyme

我正在测试React应用,并遇到以下错误:TypeError: expect(...).toBeString is not a function。我正在使用的代码是:

import React from "react";

import { configure, shallow } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import Footer from "../Footer/Footer";
configure({ adapter: new Adapter() });

describe("<About />", () => {
  it("Check the type of value", () => {
    const props = {
      copyright: "Copyright 2019"
    };
    const wrapper = shallow(<Footer {...props} />);
    expect(wrapper.prop("copyright")).toBeString();
  });
});

1 个答案:

答案 0 :(得分:1)

我想你在开玩笑。因此,toBeString不是开玩笑的匹配者。 https://jestjs.io/docs/en/expect