Ad

Faced TypeError: Expect(...).toBeString Is Not A Function When Testing React App

- 1 answer

I was testing React app and faced this error: TypeError: expect(...).toBeString is not a function. The code I am using is :

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();
  });
});
Ad

Answer

I suppose you are using jest. So, toBeString is not a matcher in jest. https://jestjs.io/docs/en/expect

Ad
source: stackoverflow.com
Ad