File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,18 @@ export function getFormField({ label, ...options }: FormFieldOptions & CommonOpt
49
49
const opts = logAndMute ( 'getFormField' , label , options )
50
50
return isUndefined ( label )
51
51
? cy . get ( '.ant-form-item' , opts )
52
- : getFormFieldLabel ( { label, ...opts } ) . closest ( '.ant-form-item' , opts )
52
+ : getFormFieldLabel ( { label, ...opts } )
53
+ // Workaround for https://github.com/cypress-io/cypress/issues/21303.
54
+ . should ( ( ) => {
55
+ // This empty assertion prevents Cypress from failing when the label does not exist.
56
+ } )
57
+ . then ( $label => {
58
+ // If the label wasn't found, do the query again but this time with the existence check on.
59
+ if ( $label . length === 0 ) {
60
+ return getFormFieldLabel ( { label, ...opts } )
61
+ }
62
+ return cy . wrap ( $label ) . closest ( '.ant-form-item' , opts )
63
+ } )
53
64
}
54
65
55
66
type FormInputOptions = FormFieldOptions & { type ?: FieldType }
You can’t perform that action at this time.
0 commit comments