-
Notifications
You must be signed in to change notification settings - Fork 60
/
core-commands.ts
27 lines (23 loc) · 990 Bytes
/
core-commands.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Cypress.Commands.add('getBy', (selector: string) => {
cy.get(selector)
.should('not.be.disabled')
.should('not.have.attr', 'aria-disabled', 'true')
.should('not.be.hidden')
.should('be.visible');
// The following line is necessary to avoid flakiness in the tests
// It's a workaround when the element is found and while assertions are running, the element is replaced
cy.get(selector);
});
Cypress.Commands.add('getByDataCy', (dataCy: string) => {
cy.getBy(`[data-cy="${dataCy}"]`);
});
Cypress.Commands.add('containsBy', (selector: string, text: string | number | RegExp) => {
cy.contains(selector, text)
.should('not.be.disabled')
.should('not.have.attr', 'aria-disabled', 'true')
.should('not.be.hidden')
.should('be.visible');
// The following line is necessary to avoid flakiness in the tests
// It's a workaround when the element is found and while assertions are running, the element is replaced
cy.contains(selector, text);
});