Giter VIP home page Giter VIP logo

Comments (9)

wswebcreation avatar wswebcreation commented on May 28, 2024

Hi @HaydenMeloche

Tnx for the compliments. Which version of CucumberJS are you using?

When I look at the docs here you are using a parser that only works for version < 0.9.0 of CucumberJS. I would advice using the cucumberMulti

I also used you logging against the parser that should work with versions higher then 0.9.0 and that also doesn't work, so it would be nice to know your version.

A workaround (I'm using this in my current project) is to add a hook like described here.
This is only for CucumberJS 1, for CucumberJS 2 you can use this piece of code

var {defineSupportCode} = require('cucumber');

defineSupportCode(function({After}) {
  After(function (scenarioResult, callback) {
    if (scenarioResult.status === 'failed') {
            // Log the spec to the console for protractor-flake to be able to rerun the failed specs
            console.log('Specs:', scenarioResult.scenario.uri);
    }
    callback();
  });
});

With this hook you are version independent.

Hope it helps

Grtz

wswebcreation

from protractor-flake.

HaydenMeloche avatar HaydenMeloche commented on May 28, 2024

@wswebcreation Thanks for the response.

I am using "cucumber": "^1.3.3".

I tried adding a hook for version 1. mention in the docs but it seems like the parser tries to read it and it errors.
LOG:
`> [email protected] test C:\OBIS\Protractor Testing

protractor-flake --parser cucumberMulti --max-attempts=2 -- protractor.conf.js

[09:21:11] I/launcher - Running 1 instances of WebDriver
[09:21:11] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[09:21:13] E/launcher - Error: CompositeParserException: Parser errors:
(1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'var {defineSupportCode} = require('cucumber');'
(3:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'defineSupportCode(function({After}) {'
(4:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'var afterHook = function () {'
(5:9): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'this.After(function (scenario, callback) {'
(6:15): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'if (scenario.isFailed()) {'
(7:19): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'console.log('Specs:', scenario.getUri());'
(8:15): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got '}'
(9:15): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'callback();'
(10:9): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got '});'
(11:7): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got '};'
(12:7): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'module.exports = afterHook;'
path: C:\OBIS\Protractor Testing\afterHooks.js
    at Function.Errors.CompositeParserException.create (C:\OBIS\Protractor Testing\node_modules\gherkin\lib\gherkin\errors.js:27:13)
    at addError (C:\OBIS\Protractor Testing\node_modules\gherkin\lib\gherkin\parser.js:88:45)
    at matchTokenAt_0 (C:\OBIS\Protractor Testing\node_modules\gherkin\lib\gherkin\parser.js:261:5)
    at matchToken (C:\OBIS\Protractor Testing\node_modules\gherkin\lib\gherkin\parser.js:149:14)
    at Parser.parse (C:\OBIS\Protractor Testing\node_modules\gherkin\lib\gherkin\parser.js:72:15)
    at C:\OBIS\Protractor Testing\node_modules\cucumber\lib\cucumber\parser.js:18:36
    at Array.forEach (native)
    at Object.parse (C:\OBIS\Protractor Testing\node_modules\cucumber\lib\cucumber\parser.js:12:22)
    at Object.getFeatures (C:\OBIS\Protractor Testing\node_modules\cucumber\lib\cucumber\runtime.js:39:35)
    at Object.start (C:\OBIS\Protractor Testing\node_modules\cucumber\lib\cucumber\runtime.js:11:27)
[09:21:13] E/launcher - Process exited with error code 100

Using cucumberMulti to parse output
Re-running tests: test attempt 2

Tests failed but no specs were found. All specs will be run again.

AfterHook.js

var {defineSupportCode} = require('cucumber');

defineSupportCode(function({After}) {
    var afterHook = function () {
        this.After(function (scenario, callback) {
              if (scenario.isFailed()) {
                  console.log('Specs:', scenario.getUri());
              }
              callback();
        });
      };
      module.exports = afterHook;
}

protractor.conf.js

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',

  framework: 'custom',
  frameworkPath: require.resolve('protractor-cucumber-framework'),

  specs: [
    'afterHooks.js',  
    'features/*.feature'
  ],
  cucumberOpts: {
    require: 'features/steps/*_steps.js',
    format: 'pretty'
  }
}

Any ideas?

from protractor-flake.

wswebcreation avatar wswebcreation commented on May 28, 2024

You added the wrong hook, the one you added was for CucumberJS 2

..A workaround (I'm using this in my current project) is to add a hook like described here.
This is only for CucumberJS 1, for CucumberJS 2 you can use this piece of code...

So take this code ;-)

from protractor-flake.

HaydenMeloche avatar HaydenMeloche commented on May 28, 2024

@wswebcreation I must be doing something else wrong. Still getting same error :(

[10:31:09] I/launcher - Running 1 instances of WebDriver
[10:31:09] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[10:31:35] E/launcher - Error: CompositeParserException: Parser errors:
(1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'var afterHook = function () {'
(2:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'this.After(function (scenario, callback) {'
(3:11): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'if (scenario.isFailed()) {'
(4:15): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'console.log('Specs:', scenario.getUri());'
(5:11): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got '}'
(6:11): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'callback();'
(7:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got '});'
(8:3): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got '};'
(10:3): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'module.exports = afterHook;'
path: C:\OBIS\Protractor Testing\afterHooks.js
    at Function.Errors.CompositeParserException.create (C:\OBIS\Protractor Testing\node_modules\gherkin\lib\gherkin\errors.js:27:13)
    at Parser.parse (C:\OBIS\Protractor Testing\node_modules\gherkin\lib\gherkin\parser.js:79:45)
    at C:\OBIS\Protractor Testing\node_modules\cucumber\lib\cucumber\parser.js:18:36
    at Array.forEach (native)
    at Object.parse (C:\OBIS\Protractor Testing\node_modules\cucumber\lib\cucumber\parser.js:12:22)
    at Object.getFeatures (C:\OBIS\Protractor Testing\node_modules\cucumber\lib\cucumber\runtime.js:39:35)
    at Object.start (C:\OBIS\Protractor Testing\node_modules\cucumber\lib\cucumber\runtime.js:11:27)
    at Object.run (C:\OBIS\Protractor Testing\node_modules\cucumber\lib\cucumber\cli.js:75:15)
    at C:\OBIS\Protractor Testing\node_modules\protractor-cucumber-framework\index.js:38:36
    at Function.promise (C:\OBIS\Protractor Testing\node_modules\q\q.js:682:9)
[10:31:35] E/launcher - Process exited with error code 100

Using cucumberMulti to parse output
Re-running tests: test attempt 2

Tests failed but no specs were found. All specs will be run again. 

from protractor-flake.

wswebcreation avatar wswebcreation commented on May 28, 2024

Can you create a simple git project and give me rights, then I'll fix it for you tonight or tomorrow.

Grtz wswebcreation

from protractor-flake.

HaydenMeloche avatar HaydenMeloche commented on May 28, 2024

@wswebcreation Sorry for wasting your time. I figured out what it was. I had require in the wrong section in protractor.conf.js................

Thanks for your help anyway!

from protractor-flake.

NickTomlin avatar NickTomlin commented on May 28, 2024

@HaydenMeloche glad you figured it out.

@wswebcreation thanks for helping debug! I wonder if we could consolidate the cucumber parsing since cucumberMulti supports both multi and non multi specs. We could work to deprecate or just drop it and make a major version bump.

from protractor-flake.

wswebcreation avatar wswebcreation commented on May 28, 2024

@HaydenMeloche

No problem

@NickTomlin

Looks like you can read minds. I first want to check what CucumberJS 3 does, was just released this week. Protractor-cucumber-framework was fixed today. Hope to get my boilerplate up and running this weekend and then will create a PR for protractor-flake to remove the CucumberJS parser so you will need to make a major.

By the way, the hook that logs a line in the console, that's also in the docs, is a more stable way to use to read the logs. Can't we also create something for Jasmine and Mocha, that will save a lot of debugging 🤔😁

from protractor-flake.

NickTomlin avatar NickTomlin commented on May 28, 2024

Yeah I think that'd be great if we could find a way to insert logging into the frameworks and not have to worry as much about parsing

from protractor-flake.

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.