cypress-promise
cypress-promise copied to clipboard
cypress-promise with async/await not working in Electron
A very good package, it is very needed and makes code easier to read. I have issues with it though.
it('should run tests with async/await', async () => {
const foo = await cy.wrap('foo').promisify();
const bar = await cy.wrap('bar').promisify();
expect(foo).to.equal('foo');
expect(bar).to.equal('bar');
});
is not working if you run it in Electron browser. I use 3.0.2 version of Cypress which comes with Electron 59.
After several experiments, I found a way to patch the promises to work in Electron. If you wrap your expect(foo).to.equal('foo'); into a Cypress command then Cypress automatically resolves the promise and you do not need async/await:
Cypress.Commands.add('toEqual', (actual, expected) => {
expect(actual).to.equal(expected);
});
then this works in the test:
it('should run tests WITHOUT async/await', () => {
const foo = cy.wrap('foo').promisify();
const bar = cy.wrap('bar').promisify();
cy.toEqual(foo, 'foo');
cy.toEqual(bar, 'bar');
});
I know this is not the way it should be but for me this workaround is good enough until cypress-promise starts to work in Electron. I'm open for suggestions that can skip wrapping into command but directly resolve the promise in the tests without async/await.
the workaround probably would still work if you remove ".promisify()" - just put the assignment into the then clause: cy....then(ele => foo = ele)
It's very possible something changed in Cypress 3 that is causing issues with the fail
event firing or the Cypress timeout happening.
There isn't much code here (about 20 lines): https://github.com/NicholasBoll/cypress-promise/blob/master/index.js
This doesn't seem to work with Electron or Firefox. The second promise does not resolve.
Not working on Chrome either if you run "yarn cypress run".
Only way got these to work is with "yarn cypress open" then run the tests with Chrome. All other browsers fail here.
Any workaround to this issue?
The second promise not resolving at all and always failing with timeout 4000 error.
I'm using Cypress 4.7.0
I love this module, but its not working in Electron. So, I cant run cypress headless.
Browser: Electron 91 (headless)
CypressError: Cypress command timeout of 10000ms
exceeded.
"devDependencies": { "@jc21/cypress-swagger-validation": "^0.1.0", "@openapitools/openapi-generator-cli": "^2.4.13", "cypress": "^8.5.0", "cypress-promise": "^1.1.0", "http": "0.0.1-security", "prettier": "^2.4.1", "request": "^2.88.2", "typescript": "^4.4.3" },
I love this module, but its not working in Electron. So, I cant run cypress headless.
Browser: Electron 91 (headless) CypressError: Cypress command timeout of
10000ms
exceeded.
"devDependencies": { "@jc21/cypress-swagger-validation": "^0.1.0", "@openapitools/openapi-generator-cli": "^2.4.13", "cypress": "^8.5.0", "cypress-promise": "^1.1.0", "http": "0.0.1-security", "prettier": "^2.4.1", "request": "^2.88.2", "typescript": "^4.4.3" },
have you got the resolution?
beside, the cypress-promise seems got command timeout in firefox