Ad
Faced TypeError: Expect(...).toBeString Is Not A Function When Testing React App
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
Related Questions
- → Import statement and Babel
- → should I choose reactjs+f7 or f7+vue.js?
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → .tsx webpack compile fails: Unexpected token <
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → React Native with visual studio 2015 IDE
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
- → How do I determine if a new ReactJS session and/or Browser session has started?
- → Alt @decorators in React-Native
- → How to dynamically add class to parent div of focused input field?
Ad