From 377e1a049e03cbbf78a63ecadf31c3460602fe06 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 9 Jul 2018 14:41:48 +0100 Subject: [PATCH] Add a test for SSR stack traces (#13180) --- .../__tests__/ReactServerRendering-test.js | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/packages/react-dom/src/__tests__/ReactServerRendering-test.js b/packages/react-dom/src/__tests__/ReactServerRendering-test.js index a07a842b33..6524b06671 100644 --- a/packages/react-dom/src/__tests__/ReactServerRendering-test.js +++ b/packages/react-dom/src/__tests__/ReactServerRendering-test.js @@ -664,4 +664,60 @@ describe('ReactDOMServer', () => { require('react-dom'); }).not.toThrow(); }); + + it('includes a useful stack in warnings', () => { + function A() { + return null; + } + + function B() { + return ( + + + + + + ); + } + + class C extends React.Component { + render() { + return {this.props.children}; + } + } + + function Child() { + return [, , ]; + } + + function App() { + return ( +
+
+ + + +
+ ); + } + + expect(() => ReactDOMServer.renderToString()).toWarnDev([ + 'Invalid ARIA attribute `ariaTypo`. ARIA attributes follow the pattern aria-* and must be lowercase.\n' + + ' in span (at **)\n' + + ' in b (at **)\n' + + ' in C (at **)\n' + + ' in font (at **)\n' + + ' in B (at **)\n' + + ' in Child (at **)\n' + + ' in span (at **)\n' + + ' in div (at **)\n' + + ' in App (at **)', + 'Invalid ARIA attribute `ariaTypo2`. ARIA attributes follow the pattern aria-* and must be lowercase.\n' + + ' in span (at **)\n' + + ' in Child (at **)\n' + + ' in span (at **)\n' + + ' in div (at **)\n' + + ' in App (at **)', + ]); + }); });