File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,20 @@ describe('find* dom-testing-library commands', () => {
119119 } )
120120 } )
121121
122+ it ( 'findByText inside within and with a previous subject' , ( ) => {
123+ cy . get ( 'section:nth-of-type(2)' ) . within ( ( ) => {
124+ cy . findByText ( / B u t t o n T e x t 1 / ) . should ( 'exist' )
125+ } )
126+ cy . get ( '#nested' )
127+ . findByText ( / B u t t o n T e x t / )
128+ . should ( 'exist' )
129+ cy . get ( 'section:nth-of-type(2)' ) . within ( ( ) => {
130+ cy . get ( '#nested' )
131+ . findByText ( / B u t t o n T e x t / )
132+ . should ( 'exist' )
133+ } )
134+ } )
135+
122136 it ( 'findByText works when another page loads' , ( ) => {
123137 cy . findByText ( 'Next Page' ) . click ( )
124138 cy . findByText ( 'New Page Loaded' ) . should ( 'exist' )
Original file line number Diff line number Diff line change @@ -6,8 +6,10 @@ function getFirstElement(jqueryOrElement) {
66}
77
88function getContainer ( container ) {
9+ const subject = cy . state ( 'subject' )
910 const withinContainer = cy . state ( 'withinSubject' )
10- if ( withinContainer ) {
11+
12+ if ( ! subject && withinContainer ) {
1113 return getFirstElement ( withinContainer )
1214 }
1315 return getFirstElement ( container )
You can’t perform that action at this time.
0 commit comments