@@ -796,6 +796,57 @@ describe('InspectedElementContext', () => {
796796 done ( ) ;
797797 } ) ;
798798
799+ it ( 'should not consume iterables while inspecting' , async done => {
800+ const Example = ( ) => null ;
801+
802+ function * generator ( ) {
803+ throw Error ( 'Should not be consumed!' ) ;
804+ }
805+
806+ const container = document . createElement ( 'div' ) ;
807+
808+ const iterable = generator ( ) ;
809+ await utils . actAsync ( ( ) =>
810+ ReactDOM . render ( < Example prop = { iterable } /> , container ) ,
811+ ) ;
812+
813+ const id = ( ( store . getElementIDAtIndex ( 0 ) : any ) : number ) ;
814+
815+ let inspectedElement = null ;
816+
817+ function Suspender ( { target} ) {
818+ const { getInspectedElement} = React . useContext ( InspectedElementContext ) ;
819+ inspectedElement = getInspectedElement ( id ) ;
820+ return null ;
821+ }
822+
823+ await utils . actAsync (
824+ ( ) =>
825+ TestRenderer . create (
826+ < Contexts
827+ defaultSelectedElementID = { id }
828+ defaultSelectedElementIndex = { 0 } >
829+ < React . Suspense fallback = { null } >
830+ < Suspender target = { id } />
831+ </ React . Suspense >
832+ </ Contexts > ,
833+ ) ,
834+ false ,
835+ ) ;
836+
837+ expect ( inspectedElement ) . not . toBeNull ( ) ;
838+ expect ( inspectedElement ) . toMatchSnapshot ( `1: Inspected element ${ id } ` ) ;
839+
840+ const { prop} = ( inspectedElement : any ) . props ;
841+ expect ( prop [ meta . inspectable ] ) . toBe ( false ) ;
842+ expect ( prop [ meta . name ] ) . toBe ( 'Generator' ) ;
843+ expect ( prop [ meta . type ] ) . toBe ( 'opaque_iterator' ) ;
844+ expect ( prop [ meta . preview_long ] ) . toBe ( 'Generator' ) ;
845+ expect ( prop [ meta . preview_short ] ) . toBe ( 'Generator' ) ;
846+
847+ done ( ) ;
848+ } ) ;
849+
799850 it ( 'should support objects with no prototype' , async done => {
800851 const Example = ( ) => null ;
801852
0 commit comments