File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
cypress/integration/commands/querying Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1230,6 +1230,16 @@ describe('src/cy/commands/querying', () => {
12301230 cy . get ( '#backslashes' ) . contains ( '"<OE_D]dQ\\' )
12311231 } )
12321232
1233+ // https://github.com/cypress-io/cypress/issues/21108
1234+ it ( 'shows correct error message when regex starts with =(equals sign)' , ( ) => {
1235+ cy . on ( 'fail' , ( err ) => {
1236+ expect ( err . message ) . to . include ( 'Expected to find content' )
1237+ } )
1238+
1239+ cy . visit ( 'fixtures/dom.html' )
1240+ cy . contains ( / = [ 0 - 6 ] / , { timeout : 100 } ) . should ( 'have.text' , 'a=2' )
1241+ } )
1242+
12331243 describe ( 'should(\'not.exist\')' , ( ) => {
12341244 it ( 'returns null when no content exists' , ( ) => {
12351245 cy . contains ( 'alksjdflkasjdflkajsdf' ) . should ( 'not.exist' ) . then ( ( $el ) => {
Original file line number Diff line number Diff line change @@ -51,6 +51,14 @@ $.find.matchesSelector = function (elem, expr) {
5151 return matchesSelector . apply ( _this , args )
5252 } ,
5353 catchFn ( e ) {
54+ // https://github.com/cypress-io/cypress/issues/21108
55+ // When regex starts with =, it is a syntax error when nothing found.
56+ // Because Sizzle internally escapes = to handle attribute selectors.
57+ // @see https://github.com/jquery/sizzle/blob/20390f05731af380833b5aa805db97de0b91268a/external/jquery/jquery.js#L4363-L4370
58+ if ( e . message . includes ( `Syntax error, unrecognized expression: :cy-contains('` ) ) {
59+ return false
60+ }
61+
5462 throw e
5563 } ,
5664 finallyFn ( ) {
You can’t perform that action at this time.
0 commit comments