mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #2960 from jsfb/add-detectable-prefix-to-reactelement-warning
Add detectable prefix to ReactElement proptype warning.
This commit is contained in:
@@ -269,7 +269,7 @@ function checkPropTypes(componentName, propTypes, props, location) {
|
||||
loggedTypeFailures[error.message] = true;
|
||||
|
||||
var addendum = getDeclarationErrorAddendum(this);
|
||||
warning(false, error.message + addendum);
|
||||
warning(false, 'Failed propType: ' + error.message + addendum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,8 @@ describe('ReactElementValidator', function() {
|
||||
});
|
||||
ReactTestUtils.renderIntoDocument(React.createElement(ParentComp));
|
||||
expect(console.warn.calls[0].args[0]).toBe(
|
||||
'Warning: Invalid prop `color` of type `number` supplied to `MyComp`, ' +
|
||||
'Warning: Failed propType: ' +
|
||||
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
|
||||
'expected `string`. Check the render method of `ParentComp`.'
|
||||
);
|
||||
});
|
||||
@@ -247,7 +248,8 @@ describe('ReactElementValidator', function() {
|
||||
|
||||
expect(console.warn.calls.length).toBe(1);
|
||||
expect(console.warn.calls[0].args[0]).toBe(
|
||||
'Warning: Required prop `prop` was not specified in `Component`.'
|
||||
'Warning: Failed propType: ' +
|
||||
'Required prop `prop` was not specified in `Component`.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -270,7 +272,8 @@ describe('ReactElementValidator', function() {
|
||||
|
||||
expect(console.warn.calls.length).toBe(1);
|
||||
expect(console.warn.calls[0].args[0]).toBe(
|
||||
'Warning: Required prop `prop` was not specified in `Component`.'
|
||||
'Warning: Failed propType: ' +
|
||||
'Required prop `prop` was not specified in `Component`.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -295,11 +298,13 @@ describe('ReactElementValidator', function() {
|
||||
|
||||
expect(console.warn.calls.length).toBe(2);
|
||||
expect(console.warn.calls[0].args[0]).toBe(
|
||||
'Warning: Required prop `prop` was not specified in `Component`.'
|
||||
'Warning: Failed propType: ' +
|
||||
'Required prop `prop` was not specified in `Component`.'
|
||||
);
|
||||
|
||||
expect(console.warn.calls[1].args[0]).toBe(
|
||||
'Warning: Invalid prop `prop` of type `number` supplied to ' +
|
||||
'Warning: Failed propType: ' +
|
||||
'Invalid prop `prop` of type `number` supplied to ' +
|
||||
'`Component`, expected `string`.'
|
||||
);
|
||||
|
||||
|
||||
@@ -752,7 +752,8 @@ describe('ReactPropTypes', function() {
|
||||
var instance = <Component num={6} />;
|
||||
instance = ReactTestUtils.renderIntoDocument(instance);
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
expect(console.warn.argsForCall[0][0]).toBe('Warning: num must be 5!');
|
||||
expect(console.warn.argsForCall[0][0]).toBe(
|
||||
'Warning: Failed propType: num must be 5!');
|
||||
});
|
||||
|
||||
it('should not warn if the validator returned anything else than an error',
|
||||
|
||||
@@ -196,7 +196,8 @@ describe('ReactJSXElementValidator', function() {
|
||||
}
|
||||
ReactTestUtils.renderIntoDocument(<ParentComp />);
|
||||
expect(console.warn.calls[0].args[0]).toBe(
|
||||
'Warning: Invalid prop `color` of type `number` supplied to `MyComp`, ' +
|
||||
'Warning: Failed propType: ' +
|
||||
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
|
||||
'expected `string`. Check the render method of `ParentComp`.'
|
||||
);
|
||||
});
|
||||
@@ -236,7 +237,8 @@ describe('ReactJSXElementValidator', function() {
|
||||
|
||||
expect(console.warn.calls.length).toBe(1);
|
||||
expect(console.warn.calls[0].args[0]).toBe(
|
||||
'Warning: Required prop `prop` was not specified in `Component`.'
|
||||
'Warning: Failed propType: ' +
|
||||
'Required prop `prop` was not specified in `Component`.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -255,7 +257,8 @@ describe('ReactJSXElementValidator', function() {
|
||||
|
||||
expect(console.warn.calls.length).toBe(1);
|
||||
expect(console.warn.calls[0].args[0]).toBe(
|
||||
'Warning: Required prop `prop` was not specified in `Component`.'
|
||||
'Warning: Failed propType: ' +
|
||||
'Required prop `prop` was not specified in `Component`.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -276,11 +279,13 @@ describe('ReactJSXElementValidator', function() {
|
||||
|
||||
expect(console.warn.calls.length).toBe(2);
|
||||
expect(console.warn.calls[0].args[0]).toBe(
|
||||
'Warning: Required prop `prop` was not specified in `Component`.'
|
||||
'Warning: Failed propType: ' +
|
||||
'Required prop `prop` was not specified in `Component`.'
|
||||
);
|
||||
|
||||
expect(console.warn.calls[1].args[0]).toBe(
|
||||
'Warning: Invalid prop `prop` of type `number` supplied to ' +
|
||||
'Warning: Failed propType: ' +
|
||||
'Invalid prop `prop` of type `number` supplied to ' +
|
||||
'`Component`, expected `string`.'
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user