3
votes

My project is build on Django and Angular.
I use protractor with cucumber and chai as my e2e test.
And using "grunt-protractor-coverage" to report code coverage. I have question here that if I use jasmine as protractor framework, when I run "grunt test" it's just fine. But when I use cucumber, error happens.

[launcher] Process exited with error code 1
/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:126
                    throw e;
                          ^
Error: Spec patterns did not match any files.
    at Runner.run (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/lib/runner.js:249:11)
    at TaskRunner.run (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/lib/taskRunner.js:123:19)
    at createNextTaskRunner (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/lib/launcher.js:220:20)
    at /Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/lib/launcher.js:243:7
    at _fulfilled (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:797:54)
    at self.promiseDispatch.done (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:826:30)
    at Promise.promise.promiseDispatch (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:759:13)
    at /Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:573:44
    at flush (/Users/paizanmay/Documents/ichef/Superadmin2.0/node_modules/protractor/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:355:11)

I really don't know how to solve it
Is "specs: ['features/store_id_admin.feature']," useless in "grunt-protractor-coverage" ?

thx

1

1 Answers

2
votes

It doesn't look like grunt-protractor-coverage was designed to work with CucumberJS. Whilst I managed to get it to read my spec list (I moved protractor.conf.js to the root of my app and specified full paths) the plugin expects specs to written as JavaScript so that they can be rewritten to collect/push coverage data back. When your tests run a small service runs in the background (coverage-collector) to collate the coverage data from each scenario.

In theory CucumberJS also provides similar hooks that could be specified along with the step definitions to record the data from window.__coverage__ object after each feature/step: https://github.com/cucumber/cucumber-js#after-hooks

(You can see the template used to write coverage data to the collector here: https://github.com/r3b/grunt-protractor-coverage/blob/master/resources/saveCoverage.tmpl)

It might be possible to add an option to the plugin to stop it trying to parse/alter spec files and get coverage data working.


Update: I've made some tweaks to grunt-protractor-coverage on my Github fork (https://github.com/gazoakley/grunt-protractor-coverage). There's a pull request to get it back to actual grunt-protractor-coverage: https://github.com/r3b/grunt-protractor-coverage/pull/44