Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
Context is no longer part of SSR stacks. This was already the case on the
client.

forwardRef no longer is wrapped on the stack. It's still in getComponentName
but it's probably just noise in stacks. Eventually we'll remove the wrapper
so it'll go away anyway. If we use native stack frames they won't have this
extra wrapper.

It also doesn't pick up displayName from the outer wrapper. We could maybe
transfer it but this will also be fixed by removing the wrapper.
  • Loading branch information
sebmarkbage committed Apr 6, 2020
1 parent b6f0b41 commit 1ce4b9a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
4 changes: 1 addition & 3 deletions packages/react/src/__tests__/ReactContextValidator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,7 @@ describe('ReactContextValidator', () => {
);
}).toErrorDev(
'Warning: Failed prop type: The prop `dontPassToSeeErrorStack` is marked as required in `Validator`, but its value is `undefined`.\n' +
' in Validator (at **)\n' +
' in MyContextType.Consumer (at **)\n' +
' in MyContextType.Provider (at **)',
' in Validator (at **)',
);
});

Expand Down
29 changes: 28 additions & 1 deletion packages/react/src/__tests__/forwardRef-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('forwardRef', () => {
).toErrorDev(
'Warning: Failed prop type: The prop `required` is marked as required in ' +
'`ForwardRef(NamedFunction)`, but its value is `undefined`.\n' +
' in ForwardRef(NamedFunction) (at **)',
' in NamedFunction (at **)',
);
});

Expand Down Expand Up @@ -242,6 +242,33 @@ describe('forwardRef', () => {
).toErrorDev(
'Warning: Failed prop type: The prop `required` is marked as required in ' +
'`Foo`, but its value is `undefined`.\n' +
' in Unknown (at **)',
);
});

it('should honor a displayName in stacks if set on the inner function', () => {
const Component = props => <div {...props} />;

const inner = (props, ref) => <Component {...props} forwardedRef={ref} />;
inner.displayName = 'Foo';
const RefForwardingComponent = React.forwardRef(inner);

RefForwardingComponent.propTypes = {
optional: PropTypes.string,
required: PropTypes.string.isRequired,
};

RefForwardingComponent.defaultProps = {
optional: 'default',
};

const ref = React.createRef();

expect(() =>
ReactNoop.render(<RefForwardingComponent ref={ref} optional="foo" />),
).toErrorDev(
'Warning: Failed prop type: The prop `required` is marked as required in ' +
'`ForwardRef(Foo)`, but its value is `undefined`.\n' +
' in Foo (at **)',
);
});
Expand Down

0 comments on commit 1ce4b9a

Please sign in to comment.