-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cypress-promise with Cypress 4.0 / cypress-cucumber-preprocessor #5
Comments
I upgraded to v4.0.1 and ran the tests in this repository and everything worked. Do you have some reproduction steps? I don't have any experience with the The tests run in this library are here: https://github.com/NicholasBoll/cypress-promise/blob/master/cypress/integration/example_spec.js |
Hi @NicholasBoll , thank you for your reply. I created an exemple project for simplify reproduction steps: Test scenarios are at: Test steps execution (code) are at: Cypress execution is same, using npx cypress open / run. This is the full output of stack trace:
Just ask me if you need any addictional information. Kind regards, |
I also created a branch with a example without cucumber-preprocessor, it worked! Just received an error at second scenario using .promisify()
Probably I missed any configuration.. Please, if you could make it work with cucumber-preprocessor it will be very appreciated. Thank you |
I was able to reproduce. I think this is related to every issue filed against this library - there is just a mismatch for how Cypress works and promises. I'm trying to figure out how to work around. Your example gets transpiled into "regenerator" code instead of actual promises: (0, _steps.Given)('I do simple request', function _callee() {
var foo;
return _regenerator["default"].async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
console.log('first');
_context.next = 3;
return _regenerator["default"].awrap((0, _cypressPromise["default"])(cy.request('https://www.google.com/')));
case 3:
foo = _context.sent;
cy.log('foo', foo);
case 5:
case "end":
return _context.stop();
}
}
});
}); There is an issue where |
I tried without any transpilation (using native async/await by the browser). It doesn't seem to make a difference. |
@jhonyasanuma Do you know if you even need this library? Cypress will already wait for previous commands to finish before new commands are run by doing command enqueuing. Updating your example import { Given, Then } from 'cypress-cucumber-preprocessor/steps';
Given('I do simple request', function () {
cy.request('https://www.google.com/').then(foo => {
cy.log('foo', foo)
});
});
Then('I check some results', function () {
cy.request('https://www.google.com/').then(bar => {
cy.log('bar', bar);
});
})
|
I was looking for some tool to improve our APIs automation suite, built in node / super test. Cypress come up with cool features, but the way we work here, using extra abstractions for services and validators layers, unfortunately didn't work well with cypress chained commands. I achieved simple scenarios using cypress alias (.as) command, but in more complex scenarios became unreadable, plus, without async/await, its add more effort for migration from super test. Thank you |
I think most people don't understand the compositional power of promises and sometimes async/await is a crutch. Code like: const foo = await getFoo()
const bar = await getBar(foo)
return await getBaz(bar) Could be written like: return getFoo()
.then(getBar)
.then(getBaz) Now there has been times I need 2 variables from 2 different promises and await is more convenient for that. I found that doesn't happen as much in Cypress test code as it does when I'm writing scripts. One of the most powerful features of Cypress chains is the retryability that is lost if you use a I made an alternative to I can understand the migration effort. I'm not sure this library can work 100%. Maybe a code transformer code |
If it'd be possible to turn cypress-promise into a transpiler, that'd be awesome (and probably safer than what it's doing now). For example: const foo = await cy.request(...).its('body.foo').promisify();
const bar = await cy.request(...).its('body.bar').promisify();
cy.request(...)
.its('body')
.should(({count}) => {
// do some stuff
}); getting converted to the following before Cypress sees it: cy.request(...)
.its('body')
.then(({foo}) => {
cy.request(...)
.its('body')
.then(({bar}) => {
cy.request(...)
.its('body')
.should(({count}) => {
// do some stuff
});
});
}); This is obviously a toy example, but it'd reduce our max indent level (currently, 9) significantly. |
Same problem here working with cucumber. Any workaround to make it work? |
Why does Cypress need to re-invent Javascript? Adds zero value wrapping native JS into Cypress-specific api that is unintuitive for developers who have been used to how promises work for a decade. Just all that needless decorator stuff, like seriously. |
sigh... cypress makes simple things complex |
Is cypress-promise still working with Cypress 4.0 and cypress-cucumber-preprocessor?
I tried this simple code:
but received a cypress error:
The text was updated successfully, but these errors were encountered: