Comments (9)
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.
@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.
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.
@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.
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.
@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.
@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.
No problem
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.
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)
- How to build with ng e2e and run config file via protractor-flake? HOT 7
- The automated release is failing 🚨 HOT 1
- Protractor-flake no show outputs in console HOT 18
- Reruning all the tests not just the failed ones with cucumber. HOT 1
- protractor-flake doesn't run tests if suite is not specified HOT 3
- protractor-flake doesn't run the remaining tests after retrying the failed test HOT 5
- protractor-flake finds the typescript file (not the compiled file) on retry HOT 5
- protractor flake executing all suites mentioned instead of specific suite HOT 2
- Feature Request: Option to mark failing and pending specs as failure to be picked up for rerun in flake
- Same failed spec being marked to run twice with cucumber HOT 3
- Failing Cucumber Scenarios causing entire feature files to re-run HOT 4
- Protractor Flake is not working with cucumber? HOT 2
- Feature Request: Expose attemptNo or allow code to be specified in beforeAttempts/afterAttempts HOT 6
- Easier way to specify path of custom parser HOT 5
- screenshots of retries overwrite the original run HOT 4
- Running serve as part of Flake HOT 4
- retryconfig doesn't work HOT 3
- running node ./protractor-flake-retry.js works putting than command inside npm run test fails HOT 3
- seleniumAddress HOT 2
- how to use protractor arguments with yarn HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protractor-flake.