Make sure the element is attached when testing
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
parent
28cfdef12d
commit
2d306dbadc
|
@ -361,9 +361,8 @@ describe('Lists', () => {
|
||||||
})
|
})
|
||||||
cy.visit('/lists/1/kanban')
|
cy.visit('/lists/1/kanban')
|
||||||
|
|
||||||
cy.get('.kanban .bucket .tasks .task')
|
cy.getAttached('.kanban .bucket .tasks .task')
|
||||||
.contains(tasks[0].title)
|
.contains(tasks[0].title)
|
||||||
.should('exist')
|
|
||||||
.click()
|
.click()
|
||||||
|
|
||||||
cy.url()
|
cy.url()
|
||||||
|
|
17
cypress/support/commands.js
Normal file
17
cypress/support/commands.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/**
|
||||||
|
* getAttached(selector)
|
||||||
|
* getAttached(selectorFn)
|
||||||
|
*
|
||||||
|
* Waits until the selector finds an attached element, then yields it (wrapped).
|
||||||
|
* selectorFn, if provided, is passed $(document). Don't use cy methods inside selectorFn.
|
||||||
|
*
|
||||||
|
* Source: https://github.com/cypress-io/cypress/issues/5743#issuecomment-650421731
|
||||||
|
*/
|
||||||
|
Cypress.Commands.add('getAttached', selector => {
|
||||||
|
const getElement = typeof selector === 'function' ? selector : $d => $d.find(selector);
|
||||||
|
let $el = null;
|
||||||
|
return cy.document().should($d => {
|
||||||
|
$el = getElement(Cypress.$($d));
|
||||||
|
expect(Cypress.dom.isDetached($el)).to.be.false;
|
||||||
|
}).then(() => cy.wrap($el));
|
||||||
|
});
|
|
@ -1,2 +1,3 @@
|
||||||
|
|
||||||
|
import './commands'
|
||||||
import 'cypress-file-upload'
|
import 'cypress-file-upload'
|
||||||
|
|
Reference in New Issue
Block a user