IssueRaiser

Await-ing Cypress Chains

### Current behavior: `await`-ing cypress chains yields undefined ### Desired behavior: `await`-ing cypress chains yields the value of the chain (since the chain is a promise-like, it should work with await out of the box) ### Additional Info (images, stack traces, etc) I understand the recommended way to use cypress is closures, however, when dealing with multiple variables, we run into callback hell's lil' brother **closure hell**. The ability to use `await` on Cypress chains could be beneficial in many ways: - avoiding nesting closures many levels deep, thus preventing unreadable code - making it easy for programmers familiar with traditional async patterns to start using Cypress Example code using closures ````js describe('Filter textbox', () => { beforeEach(() => { cy.get(test("suplovaniTable")).as("suplovaniTable"); cy.get(test("filterTextbox")).as("filterTextbox"); }); it('changes data on filter text change', () => { cy.get("@suplovaniTable").then((el) => { return el[0].innerHTML; }).then((innerHTML) => { return sha256(innerHTML); }).then((hash) => { cy.get("[data-test=suplovaniTable] > tbody > :nth-child(1) > :nth-child(2)") .then((tds) => { const text = tds[0].innerText; cy.get("@filterTextbox").type(text); cy.get("@suplovaniTable") .then(el => el[0].innerHTML)

Posted by vacekj on Mar 5, 2018, 12:34 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

github (Other)

Await-ing Cypress Chains

vacekjMar 5, 2018, 12:34 PM

### Current behavior: `await`-ing cypress chains yields undefined ### Desired behavior: `await`-ing cypress chains yields the value of the chain (since the chain is a promise-like, it should work with await out of the box) ### Additional Info (images, stack traces, etc) I understand the recommended way to use cypress is closures, however, when dealing with multiple variables, we run into callback hell's lil' brother **closure hell**. The ability to use `await` on Cypress chains could be beneficial in many ways: - avoiding nesting closures many levels deep, thus preventing unreadable code - making it easy for programmers familiar with traditional async patterns to start using Cypress Example code using closures ````js describe('Filter textbox', () => { beforeEach(() => { cy.get(test("suplovaniTable")).as("suplovaniTable"); cy.get(test("filterTextbox")).as("filterTextbox"); }); it('changes data on filter text change', () => { cy.get("@suplovaniTable").then((el) => { return el[0].innerHTML; }).then((innerHTML) => { return sha256(innerHTML); }).then((hash) => { cy.get("[data-test=suplovaniTable] > tbody > :nth-child(1) > :nth-child(2)") .then((tds) => { const text = tds[0].innerText; cy.get("@filterTextbox").type(text); cy.get("@suplovaniTable") .then(el => el[0].innerHTML)

Comments (0)

No comments yet. Start the discussion.

Comment on this issue