cucumber-js icon indicating copy to clipboard operation
cucumber-js copied to clipboard

HTML formatter with external attachments does not show plain text when opened from local filesystem

Open vitalets opened this issue 1 year ago • 2 comments

👓 What did you see?

I have the following step that attaches plain text:

Given('some step', async function () {
   this.attach('some text');
});

I run Cucumber with HTML formatter and external attachments enabled:

format: [
  ['html', 'cucumber-reports/report.html'],
],
formatOptions: {
  html: {
    externalAttachments: true
  }
}

When I open report.html from the local filesystem, I see the following error: image

✅ What did you expect to see?

I expect that some text would be displayed in the report.

📦 Which tool/library version are you using?

$ npx cucumber-js -v
11.0.1

🔬 How could we reproduce it?

No response

📚 Any additional context?

No response

vitalets avatar Sep 26 '24 10:09 vitalets

Sorry for the late reply @vitalets, this is unfortunate with the content being fetch'd and thus subject to CORS policy.

I'm thinking we could offer a bit more granularity for the externalAttachments option, something like:

  • NONE - nothing externalised
  • BINARY - images, videos and other binary files are externalised (since these don't run into CORS issues), but nothing else
  • ALL - everything externalised except logs

And have true become an alias for BINARY as good default for users who want to save file size.

What do you think?

(We could also give some advice in the docs that if you have externalised text attachments you could run a local web server to view the report, which would work fine.)

davidjgoss avatar Nov 23 '24 11:11 davidjgoss

Another option is to filter attachments by content-type. E.g.

formatOptions: {
  html: {
    externalAttachments: ['video/*', 'image/*']
  }
}

Even more granular control, but more setup. Anyway, internally we need to map BINARY to some set of content-types.

vitalets avatar Nov 24 '24 05:11 vitalets