Skip to content
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

promisify() doesn't work together with cypress-cucumber-preprocessor #11

Open
johnknoop opened this issue Jan 1, 2021 · 1 comment
Open

Comments

@johnknoop
Copy link

Hi!

I'm using the Cypress plugin cypress-cucumber-preprocessor which lets you write Cypress tests in BDD format.

It means you have your .feature file that expresses your test scenarios, and then you have js/ts files where you define your "step definitions" that are effectively just the where you implement the test code.

So in order to have a step definition for the step When I do xxx, you add this code:

When('I do xxx', function () {
    // Implement step
});

These step definition functions may be async as well. For example, this works:

// my-working-spec.ts

When('some step', async function () {
	const data = await new Promise(resolve => {
		setTimeout(() => {
			resolve('mock data');
		}, 1000);
	});
	console.log(data);
});

So cypress-cucumber-preprocessor seems to be able to handle async step definitions just fine.

But when I use promisify like this;

// my-failing-spec.ts

import promisify from 'cypress-promise';

When('some step', async function () {
	const data = await promisify(cy.task('LoadDataFromDatabase'));
	console.log(data);
});

then I get this error:

image

I'm not super versed in the internals of Cypress, so it's hard for me to tell where it goes wrong, but the fact that other async step definitions work fine suggests that it's something to do with cypress-promise.

@richardszanyi-kasa
Copy link

Up, encountered the same problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants