mavdi / grunt-cucumberjs

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

Unable to parse cucumberjs output into json. #15

Closed j2ro closed 9 years ago

j2ro commented 10 years ago

I am getting the following error intermittently when running my cucumber tests, and producing a HTML report via grunt-cucumberjs:

"Unable to parse cucumberjs output into json."

It looks like that this is thrown on line 88 of cucumber.js.

I think this is happening because when my cucumber test suite finishes, it runs an After block, which in turn writes to sysout. This output in turn is then getting appended to the end of the JSON output, and thus is no longer valid JSON.

mavdi commented 10 years ago

Are you console.log ing an array or something in your step definitions? If so, try to remove it.

bspates commented 10 years ago

I am having the same issue, and I do no console.logs within my step defs.

mavdi commented 10 years ago

Do you happen to use cucumber Background steps?

bspates commented 10 years ago

Nope, I'm just running two scenarios in one feature at the moment.

mavdi commented 10 years ago

I see.

Can you open the module in your node_modules/grunt-cucumberjs/tasks/cucumber.js

go to line 101:

try {
          featureJsonOutput = JSON.parse(featureOutput);
        } 

And try to log featureOutput, there is a problem with parsing the output as Json and I need to see what the reason is.

Thanks.

j2ro commented 10 years ago

I am not using console.log in my step definitions, but my applications are logging to stdout (using Winston).

When I log featureOutput, sometimes I see the console output included after the JSON report section, hence why the JSON parsing fails. However, this is intermittent. Sometimes it works and sometimes not (it depends if the console was written to whilst the JSON report was being generated).

mavdi commented 10 years ago

In both your cases I would need to see a failing example.

The issue we have is that we spawn cucumber as a command, which dumps the report along with everything else into console. Extracting that can be difficult.

I've raised this issue with them, let's see what they come back with.

https://github.com/cucumber/cucumber-js/issues/205

bspates commented 10 years ago

Looks like they've had this PR open for a bit https://github.com/cucumber/cucumber-js/pull/188

mavdi commented 10 years ago

OK....

I might know what the problem is....

So the same issue happened to me, and after digging for a couple of hours I realised that this step doesn't work

And all "updatedTime" properties should be in the last "1" hour

Cucumber skips it! Further more no json output is produced

but changing it to this work!

And I see all "updatedTime" properties should be in the last "1" hour

I would recommend deleting all but one of your feature files, running the task and see if it works. Then add the other feature files and see if you have a similar issue.

Meanwhile I will raise an issue with them

mavdi commented 9 years ago

this should be fixed with latest cucumber