I have to leave all tests empty, which gives a false status of passing and fails on guiding the development process.
Is there any way to do it? Or am I missing it? #
I think this is more of a cypress / mocha thing - what happens if you put this.skip() inside your step definition?
It just skips it, and the test itself marks as passing (if only skipped steps are left)
I've tried to throw an error saying "Step pending" or just not write the step until I get to it, but both cases, it seems to override the entire test ,Cypress doesn't show the other steps that were executed before. i.e. I have a step that is pending, where I just do an 'assert.isTrue(false)'. The error emerges, but it does not show the previous steps
return this.pending();
would be how to to it in mocha, but how to get this to be the right context from a step definition.
this.skip() does not work for me
I would love to have a way to write specs that are 'Pending' in the sense of a 'TODO: Write this step'. The following is what Cypress does with Mocha tests:
describe('My First Test', function () {
// Runs and passes
it('Does something at least!', function () {
expect(true).to.equal(true)
})
// Runs and passes
it('Does nothing', function () {
})
// Is skipped, using Mocha function
it('Skips', function () {
this.skip()
})
// Is also skipped, by having no function
it('Some other step for later')
// Runs despite the skip() above
it('Does the last step', function () {
expect(true).to.equal(true)
})
})
The 2 skipped steps are reported in the pale blue highlight in the log panel and the final step runs.
So, given this feature:
Feature: My First Test
As a user I want test the Cypress syntax
Scenario: Start first app
Given I start the app
Then Does something at least!
Then Some other step for later
Then Skips
Then Does the last step
And this step def:
Given('I start the app', () => {
Then(`Does something at least!`, () => {
expect(true).to.equal(true);
})
Then(`Some other step for later`)
Then(`Skips`, function () {
this.skip()
})
Then(`Does the last step`, () => {
expect(true).to.equal(true);
})
})
Then('Some other step for later') (no function) throws an error Error: Step implementation missing for: Some other step for later. Removed it and ran again.
This does tell Cypress to skip:
Then('Skips', function () {
this.skip()
})
ie it displays the pale blue "skipped" style, but it also prevents any further steps from running (unlike the Mocha test above which executed the remaining step).
If I change it to this:
Then('Skips', function () {
//this.skip()
})
all steps run (and the Log entries are after 2 Passing assertions). The 'Skips' step is just logged.
If I remove that Then('Skips'... step altogether the 2 passing assertions run (and the Log entries are after 2 Passing assertions).
So, in Mocha / Cypress, the this.skip() can be used inside the step definition as a "To do later". In this cypress-cucumber-preprocessor we can use this.skip() but the outcome is any steps following are not run.
Are my assumptions correct here and is there any way we can have this.step() behave here as it does in Mocha / Cypress?
Thanks. It is just a small thing but would be great to have it work so we can visually see which feature steps are not yet implemented.
Cheers,
Murray
I see what you are saying and I would love to have that as well, but at this moment I don't see a way to achieve that, as Cypress forces us to treat all steps as one test. you can try to introduce a warning instead of the this.skip but that will be easy to miss for example in the CI (which is the point of pending tests as far as I understand).
I think we would need some changes in the cypress runner here, possibly around the way they deal with loging.
This is something I was hoping to look at in November.
OK. All good. Just as long as it is on the radar!
Thanks,
Murray
Hello - any updates on the development of this feature?
This feature would be awesome... right now, not being able to set a scenario as "pending" with cucumber is what's hindering me from using cypress...
Any update here?
My use case is the following:
I want to mark tests, which are not implemented yet, so that they do not break the CI build.
The idea was to give a custom tag and then, in the before hook, skip the whole scenario.
Of course, I would be possible to ignore the scenarios with those tags, but it would be nice to still have the steps in the cucumber report. That's why I would prefer to have them skipped.
Is there a way to do that? I came up with an approach like that, but I can not seem to get it running:
Before({ tags: '@manual' }, function() {
console.log('In before hook');
this.skip();
// return 'skipped';
});
Is there a way to achieve that right now?
Any update on this?
It is a good feature to have. As right now, the result table of the test show pending
Anyone here found a way to achieve the desired behaviour?
I have used cucumber with Java and to acheive this you throw a PendingException() is there a similar concept that can be used here?
While this doesn't address the bigger issue, this is helpful: https://github.com/cypress-io/cypress-skip-test
eg:
Then('Skip this test', () => {
cy.skipOn(true)
});
Most helpful comment
I would love to have a way to write specs that are 'Pending' in the sense of a 'TODO: Write this step'. The following is what Cypress does with Mocha tests:
The 2 skipped steps are reported in the pale blue highlight in the log panel and the final step runs.
So, given this feature:
And this step def:
Then('Some other step for later')(no function) throws an errorError: Step implementation missing for: Some other step for later. Removed it and ran again.This does tell Cypress to skip:
ie it displays the pale blue "skipped" style, but it also prevents any further steps from running (unlike the Mocha test above which executed the remaining step).
If I change it to this:
all steps run (and the Log entries are after 2 Passing assertions). The 'Skips' step is just logged.
If I remove that
Then('Skips'...step altogether the 2 passing assertions run (and the Log entries are after 2 Passing assertions).So, in Mocha / Cypress, the
this.skip()can be used inside the step definition as a "To do later". In this cypress-cucumber-preprocessor we can usethis.skip()but the outcome is any steps following are not run.Are my assumptions correct here and is there any way we can have
this.step()behave here as it does in Mocha / Cypress?Thanks. It is just a small thing but would be great to have it work so we can visually see which feature steps are not yet implemented.
Cheers,
Murray