Add a test for SSR stack traces (#13180)
Dan Abramov committed
Jul 9, 2018 at 14:41 UTC
377e1a049e03cbbf78a63ecadf31c3460602fe06
1 file changed
+56
packages/react-dom/src/__tests__/ReactServerRendering-test.js
+56
@@ -664,4 +664,60 @@ describe('ReactDOMServer', () => {
664
require('react-dom');
665
}).not.toThrow();
666
});
667
+
668
+ it('includes a useful stack in warnings', () => {
669
+ function A() {
670
+ return null;
671
+ }
672
+
673
+ function B() {
674
+ return (
675
+ <font>
676
+ <C>
677
+ <span ariaTypo="no" />
678
+ </C>
679
+ </font>
680
+ );
681
+ }
682
+
683
+ class C extends React.Component {
684
+ render() {
685
+ return <b>{this.props.children}</b>;
686
+ }
687
+ }
688
+
689
+ function Child() {
690
+ return [<A key="1" />, <B key="2" />, <span ariaTypo2="no" />];
691
+ }
692
+
693
+ function App() {
694
+ return (
695
+ <div>
696
+ <section />
697
+ <span>
698
+ <Child />
699
+ </span>
700
+ </div>
701
+ );
702
+ }
703
+
704
+ expect(() => ReactDOMServer.renderToString(<App />)).toWarnDev([
705
+ 'Invalid ARIA attribute `ariaTypo`. ARIA attributes follow the pattern aria-* and must be lowercase.\n' +
706
+ ' in span (at **)\n' +
707
+ ' in b (at **)\n' +
708
+ ' in C (at **)\n' +
709
+ ' in font (at **)\n' +
710
+ ' in B (at **)\n' +
711
+ ' in Child (at **)\n' +
712
+ ' in span (at **)\n' +
713
+ ' in div (at **)\n' +
714
+ ' in App (at **)',
715
+ 'Invalid ARIA attribute `ariaTypo2`. ARIA attributes follow the pattern aria-* and must be lowercase.\n' +
716
+ ' in span (at **)\n' +
717
+ ' in Child (at **)\n' +
718
+ ' in span (at **)\n' +
719
+ ' in div (at **)\n' +
720
+ ' in App (at **)',
721
+ ]);
722
+ });
723
});