Hi All,
Wondering if anyone has been able to attach/embed png image into the cucumber.json file, as I am having issues with the base64 encoding.
The problem I am facing is when calling scenario.attach(data, '[encoding]') the expected base64 string is not embedded in the cucumber.json file instead its something else (which I am not sure of)
So with that in mind here are the steps I took.
1. Converted an image to base64 ( I have hard coded it, to remove any confusion in explaining this, typically this would be done by browser.takeScreenshot().then (function (png) { scenario.attach(new Buffer(png, 'base64'), 'image/png') });
var imgBase64 = "iVBORw0KGgoAAAANSUhEUgAABAoAAALvCAI....."
3. scenario.attach(new Buffer(imgBase64, 'base64'), 'image/png;base64')
4. when viewing the cucumber.json file I received.
"embeddings": [
{
"mime_type": "image/png;base64",
"data": "//3//f/9//0AEEpGSUYAAQEAAAEAAQAA//3//QD//QAJBgc...."
In Item 4, I was actually expecting
"embeddings": [
{
"mime_type": "image/png;base64",
"data": "iVBORw0KGgoAAAANSUhEUgAABAoAAALvCAI....."
Can someone please tell me what I am doing wrong here. At step 3, I have also tried
scenario.attach(imgBase64, 'base64') and other various combinations
decoding the img before passing it to the scenario.attach method
and many other different combinations, (just not the one that works)
Please note if I insert the imgBase64 string directly into the cucumber.json file I am able to run the html report generator using cucumber-sandwich and the image is displayed fine.
So I suspect that issue lies with how the data is passed to scenario.attach