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', () => {
119
119
} )
120
120
} )
121
121
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
+
122
136
it ( 'findByText works when another page loads' , ( ) => {
123
137
cy . findByText ( 'Next Page' ) . click ( )
124
138
cy . findByText ( 'New Page Loaded' ) . should ( 'exist' )
Original file line number Diff line number Diff line change @@ -6,8 +6,10 @@ function getFirstElement(jqueryOrElement) {
6
6
}
7
7
8
8
function getContainer ( container ) {
9
+ const subject = cy . state ( 'subject' )
9
10
const withinContainer = cy . state ( 'withinSubject' )
10
- if ( withinContainer ) {
11
+
12
+ if ( ! subject && withinContainer ) {
11
13
return getFirstElement ( withinContainer )
12
14
}
13
15
return getFirstElement ( container )
You can’t perform that action at this time.
0 commit comments