cucumber-attic / gherkin2

A fast Gherkin parser in Ragel (The parser behind Cucumber)
MIT License
382 stars 221 forks source link

JS JSONFormatter - No way to attach an embedding without base64 encoding #317

Closed simondean closed 9 years ago

simondean commented 9 years ago

Hi. The js/lib/gherkin/formatter/json_formatter.js provides a embedding(mime_type, data) function for adding an embedding to a step. The function always base64 encodes the data. There's no way to create an embedding without base64 encoding. This means that a text-base embedding (e.g. plain text, JSON etc) cannot not be created without base64 encoding which means you can't read them in the JSON report without first base64 decoding. I'd like to use this embedding function to fix https://github.com/cucumber/cucumber-js/issues/233 but the mandatory base64 encoding makes it difficult. I could use the embeddings() function instead but that's marked as a "private function" and that would be a bit of a hack.

simondean commented 9 years ago

Just noticed the embeddings() function actually is private. That means there is no way to attach a text-based embedding without it being base64 encoded.

simondean commented 9 years ago

Thinking about it, I realise that the Cucumber JSON format only supports base64 encoded embeddings/attachments. Otherwise anything consuming the reports wouldn't know whether to base64 decode or not.