Created
February 11, 2025 17:45
-
-
Save rowellx68/c94d305e5f4d32ae0a8eb80d597c23a0 to your computer and use it in GitHub Desktop.
Selecting option from Mantine Select
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable @typescript-eslint/no-namespace */ | |
/// <reference types="cypress" /> | |
declare global { | |
namespace Cypress { | |
interface Chainable { | |
selectMantine( | |
optionText: string, | |
options?: Partial< | |
Cypress.Loggable & | |
Cypress.Timeoutable & | |
Cypress.Withinable & | |
Cypress.Shadow | |
> | |
): Chainable<JQuery<HTMLElement>>; | |
} | |
} | |
} | |
Cypress.Commands.add('selectMantine', { prevSubject: true }, (subject, optionText, options) => { | |
cy.wrap(subject).get('input.mantine-Select-input').click(); | |
cy.wrap(subject).get('label.mantine-Select-label').then((label) => { | |
cy.get(`[aria-labelledby="${label.attr('id')}"].mantine-Select-options .mantine-Select-option`, options) | |
.contains(optionText).click(); | |
}); | |
return cy.wrap(subject).get('input.mantine-Select-input'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment