GithubHelp home page GithubHelp logo

Comments (17)

flowt-au avatar flowt-au commented on July 20, 2024 4

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

from cypress-cucumber-preprocessor.

lgandecki avatar lgandecki commented on July 20, 2024 2

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.

from cypress-cucumber-preprocessor.

pascalbe-dev avatar pascalbe-dev commented on July 20, 2024 2

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?

from cypress-cucumber-preprocessor.

badeball avatar badeball commented on July 20, 2024 1

Due to personal reasons, the previous maintainers of this package are stepping down and handing the reigns over to me, a long-time contributor to the project and a user of it myself. This is a responsibility I'm very excited about. Furthermore, I'd like to thank @lgandecki ++ for all the work that they've done so far.

Read more about the transfer of ownership here.

The repository has however moved and all outstanding issues are being closed. This is not a reflection of the perceived importance of your reported issue. However, if after upgrading to the new version, you still find there to be an issue, feel free to open up another ticket or comment below. Please make sure to read CONTRIBUTING.md before doing so.

from cypress-cucumber-preprocessor.

lgandecki avatar lgandecki commented on July 20, 2024

I think this is more of a cypress / mocha thing - what happens if you put this.skip() inside your step definition?

from cypress-cucumber-preprocessor.

victorheid avatar victorheid commented on July 20, 2024

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

from cypress-cucumber-preprocessor.

haleagar avatar haleagar commented on July 20, 2024

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

from cypress-cucumber-preprocessor.

flowt-au avatar flowt-au commented on July 20, 2024

OK. All good. Just as long as it is on the radar!

Thanks,
Murray

from cypress-cucumber-preprocessor.

miteshpatel1 avatar miteshpatel1 commented on July 20, 2024

Hello - any updates on the development of this feature?

from cypress-cucumber-preprocessor.

servandoprime avatar servandoprime commented on July 20, 2024

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...

from cypress-cucumber-preprocessor.

ncko avatar ncko commented on July 20, 2024

Any update on this?

from cypress-cucumber-preprocessor.

AlphaWong avatar AlphaWong commented on July 20, 2024

It is a good feature to have. As right now, the result table of the test show pending

from cypress-cucumber-preprocessor.

gtsop avatar gtsop commented on July 20, 2024

Anyone here found a way to achieve the desired behaviour?

from cypress-cucumber-preprocessor.

andyg101 avatar andyg101 commented on July 20, 2024

I have used cucumber with Java and to acheive this you throw a PendingException() is there a similar concept that can be used here?

from cypress-cucumber-preprocessor.

flowt-au avatar flowt-au commented on July 20, 2024

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) });

from cypress-cucumber-preprocessor.

mkefd avatar mkefd commented on July 20, 2024

hi! when using this.skip() I get empty.cucumber.json generated instead of some meaningful data, does anyone experiences the same?

versions

"cypress": "^9.0.0",
"cypress-cucumber-preprocessor": "^4.3.0",

config

  "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": true,
    "cucumberJson": {
      "generate": true,
      "outputFolder": "cypress/cucumber-json",
      "filePrefix": "",
      "fileSuffix": ".cucumber"
    }
  }

from cypress-cucumber-preprocessor.

Finaldrace avatar Finaldrace commented on July 20, 2024

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) });

Yeah i use the skip-test plugin too.
And in CLI the testcases with the cy.skipOn("true") are marked as pending.

image
As you can see 5 are pending.

but in my json file is every expected "status": "pending" testcase missing.

from cypress-cucumber-preprocessor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.