Cucumber-js: How to stop test running at first failure?

Created on 6 Jul 2016  路  7Comments  路  Source: cucumber/cucumber-js

I need to stop my tests on the first failure found, I'm also using Protractor. I had created:

    this.After(function (scenario, callback) {
        if (scenario.isFailed()) {
            browser.takeScreenshot().then(function(png) {
                var decodedImage = new Buffer(png, 'base64').toString('binary');
                scenario.attach(decodedImage, 'image/png');
                browser.quit();
                callback();
            });
        } else {
            callback();
        }
    });

But I don't like at all this approach! the problem is that for the rest of the scenarios I had an error that's confusing if another team member sees it! can you help? I looked around and didn't found a thing!

Thanks

Most helpful comment

cucumber-js has a --fail-fast CLI option which will stop the test run after the first failure.

All 7 comments

cucumber-js has a --fail-fast CLI option which will stop the test run after the first failure.

I had tried that and seems not to be working, I have a npm task like "e2e-local": "scripts/test-e2e.sh local" that executes: grunt test:e2e:"$1" --tags "$2" and the protractor task in the grunt file looks like:

      // Functional test configuration
        protractor: {
            options: {
                configFile: 'test/protractor-devel-conf.js',
                keepAlive: false,
                noColor: false,
                args: {
                    cucumberOpts: {
                        tags: grunt.option('tags')
                    }
                }
            },
            local: {
                options: {
                    configFile: 'test/protractor-devel-conf.js',
                    keepAlive: false
                }
            },
            live: {
                options: {
                    configFile: 'test/protractor-live-conf.js',
                    keepAlive: false
                }
            }
        },

I had tried to add the --fail-fast at all points that calls, such in:

  • npm run e2e-local --tags @TAG --fail-fast and didn't work
  • grunt test:e2e:"$1" --tags "$2" --fail-fast but neither...

I cannot see what I'm doing wrong! can you tell!?

I believe you should actually be asking this question on the repo for the grunt plugin you are using. My hunch would be that you need to add something to the cucumberOpts block in your configuration.

@bmsoko any update on this? If not going to close this out

closing due to inactivity. Please reopen if needed

@charlierudolph thank you very much for the responses! I haven't contacted the grunt plugin developers with this question, but will do soon and let you'll know about it.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings