mavdi / grunt-cucumberjs

Grunt plugin for cucumber.js
MIT License
31 stars 36 forks source link

Global variables not persisted through cucumberjs task #105

Open dmruczek opened 7 years ago

dmruczek commented 7 years ago

It seems that somewhere along the line of executing the cucumberjs task, global variables are lost. This is problematic when trying to use grunt-cucumberjs with something like grunt-istanbul which uses a global __coverage__ variable to store coverage information.

dmruczek commented 7 years ago

After some further investigation, it looks like this problem can be solved by setting the "debugger" option within the cucumberjs task to "true". When you do this, cucumberjs uses "requireHandler" to run your scenarios within the current Node process. Without this setting, cucumberjs uses "processHandler", which spawns a new separate Node process to run your scenarios (which is why the global variable set during the execution of the scenarios is not persisted).

It might be helpful to add some information about this to the documentation, as it looks like the "debugger" option may be useful for more than just debugging within the IDE!