Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vitalets opened this issue Sep 26, 2024 · 2 comments
Labels
🐛 bug Defect / Bug

Comments

@vitalets
Copy link

vitalets commented Sep 26, 2024

👓 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

@davidjgoss
Copy link
Contributor

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 davidjgoss added the 🐛 bug Defect / Bug label Nov 23, 2024
@vitalets
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug
Projects
None yet
Development

No branches or pull requests

2 participants