Skip to content

Commit

Permalink
Updated PropTypes test to work with newer prop-types version (#9471)
Browse files Browse the repository at this point in the history
The prop-types lib got an anti-spamming change in 15.5.8 that broke some of our tests (see reactjs/prop-types/commit/e1d51dd0efbd0eee5e4a8d24759f2a4d518721d3). This PR resolves that by resetting the prop-types import between tests.
  • Loading branch information
bvaughn committed Apr 20, 2017
1 parent 28bc886 commit 73ca894
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -22,6 +22,7 @@ var MyComponent;
function resetWarningCache() {
jest.resetModules();
checkPropTypes = require('prop-types/checkPropTypes');
PropTypes = require('ReactPropTypes');
}

function getPropTypeWarningMessage(propTypes, object, componentName) {
Expand Down Expand Up @@ -99,6 +100,7 @@ function expectWarningInDevelopment(declaration, value) {
var props = {testProp: value};
var propName = 'testProp' + Math.random().toString();
var componentName = 'testComponent' + Math.random().toString();
resetWarningCache();
for (var i = 0; i < 3; i++) {
declaration(props, propName, componentName, 'prop');
}
Expand All @@ -111,7 +113,6 @@ function expectWarningInDevelopment(declaration, value) {

describe('ReactPropTypes', () => {
beforeEach(() => {
PropTypes = require('ReactPropTypes');
React = require('react');
ReactDOM = require('react-dom');
resetWarningCache();
Expand Down

0 comments on commit 73ca894

Please sign in to comment.