Jest shows console.warn for Accessing PropTypes and createClass

Viewed 721

I'm testing a React component using Jest. The test runs fine, but I get a few console.warn messages that are very annoying. I'm not using either PropTypes or createClass myself, so I'm suspecting this comes from some library. Is there some way to figure out where they are coming from, or suppress them?

PASS  src/__tests__/title.test.ts
  ● Console

    console.warn node_modules/react/lib/lowPriorityWarning.js:40
      Warning: Accessing PropTypes via the main React package is deprecated, and will be removed in  React v16.0. Use the latest available v15.* prop-types package from npm instead. For info on usage, compatibility, migration and more, see
    console.warn node_modules/react/lib/lowPriorityWarning.js:40
      Warning: Accessing createClass via the main React package is deprecated, and will be removed in React v16.0. Use a plain JavaScript class instead. If you're not yet ready to migrate, create-react-class v15.* is available on npm as a temporary, drop-in replacement. For more info see 

The test looks like this

import { shallow } from "enzyme";
import * as React from "react";
import {Title} from "../components/title";

describe("Testing title component", () => {
  it("renders", () => {
    const titleElement: React.ReactElement<{}> = React.createElement(Title);
    const component = shallow(titleElement);
    const text = component.text();
    expect(text).toBe("test");
  });
});

and the component looks like this

import * as React from "react";

export class Title extends React.Component<{}, {}> {

  constructor(props: {}) {
    super(props);
  }

  public render(): React.ReactElement<{}> {
    return <p>test</p>;
  }

}
1 Answers
Related