@@ -88,18 +88,15 @@ describe('find* dom-testing-library commands', () => {
8888 /* Test the behaviour around these queries */
8989
9090 it ( 'findByText should handle non-existence' , ( ) => {
91- cy . findByText ( 'Does Not Exist' )
92- . should ( 'not.exist' )
91+ cy . findByText ( 'Does Not Exist' ) . should ( 'not.exist' )
9392 } )
9493
9594 it ( 'findByText should handle eventual existence' , ( ) => {
96- cy . findByText ( 'Eventually Exists' )
97- . should ( 'exist' )
95+ cy . findByText ( 'Eventually Exists' ) . should ( 'exist' )
9896 } )
9997
10098 it ( 'findByText should handle eventual non-existence' , ( ) => {
101- cy . findByText ( 'Eventually Not exists' )
102- . should ( 'not.exist' )
99+ cy . findByText ( 'Eventually Not exists' ) . should ( 'not.exist' )
103100 } )
104101
105102 it ( "findByText with should('not.exist')" , ( ) => {
@@ -111,7 +108,7 @@ describe('find* dom-testing-library commands', () => {
111108
112109 it ( 'findByText with a previous subject' , ( ) => {
113110 cy . get ( '#nested' )
114- . findByText ( 'Button Text 1' , { fallbackRetryWithoutPreviousSubject : false } )
111+ . findByText ( 'Button Text 1' , { fallbackRetryWithoutPreviousSubject : false } )
115112 . should ( 'not.exist' )
116113 cy . get ( '#nested' )
117114 . findByText ( 'Button Text 2' )
@@ -170,8 +167,7 @@ describe('find* dom-testing-library commands', () => {
170167 expect ( err . message ) . to . contain ( errorMessage )
171168 } )
172169
173- cy . findByText ( 'Button Text 1' , { timeout : 100 } )
174- . should ( 'not.exist' )
170+ cy . findByText ( 'Button Text 1' , { timeout : 100 } ) . should ( 'not.exist' )
175171 } )
176172
177173 it ( 'findByLabelText should forward useful error messages from @testing-library/dom' , ( ) => {
@@ -196,11 +192,14 @@ describe('find* dom-testing-library commands', () => {
196192 cy . window ( )
197193 . findByText ( 'Button Text 1' )
198194 . should ( 'exist' )
195+ cy . location ( )
196+ . findByText ( 'Button Text 1' )
197+ . should ( 'exist' )
199198 } )
200199
201200 it ( 'findByText should show as a parent command if it starts a chain' , ( ) => {
202201 const assertLog = ( attrs , log ) => {
203- if ( log . get ( 'name' ) === 'findByText' ) {
202+ if ( log . get ( 'name' ) === 'findByText' ) {
204203 expect ( log . get ( 'type' ) ) . to . equal ( 'parent' )
205204 cy . off ( 'log:added' , assertLog )
206205 }
@@ -211,14 +210,25 @@ describe('find* dom-testing-library commands', () => {
211210
212211 it ( 'findByText should show as a child command if it continues a chain' , ( ) => {
213212 const assertLog = ( attrs , log ) => {
214- if ( log . get ( 'name' ) === 'findByText' ) {
213+ if ( log . get ( 'name' ) === 'findByText' ) {
215214 expect ( log . get ( 'type' ) ) . to . equal ( 'child' )
216215 cy . off ( 'log:added' , assertLog )
217216 }
218217 }
219218 cy . on ( 'log:added' , assertLog )
220219 cy . get ( 'body' ) . findByText ( 'Button Text 1' )
221220 } )
221+
222+ it ( 'should chain findBy* with subject different of document, element or window' , ( ) => {
223+ cy . wrap ( true )
224+ . should ( 'be.true' )
225+ . findByText ( 'Error message' )
226+ . findByLabelText ( / R e q u i r e d / i)
227+ . type ( 'something' )
228+ . findByText ( 'Submit' )
229+ . queryByText ( 'Error message' )
230+ . should ( 'not.be.visible' )
231+ } )
222232} )
223233
224234/* global cy */
0 commit comments