cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.04k stars 1.09k forks source link

Support for pdf attachments #2277

Closed maxjoehnk closed 1 year ago

maxjoehnk commented 1 year ago

πŸ€” What's the problem you're trying to solve?

The test suite we've built is capable of downloading a pdf and checking for certain texts. When the pdf generation or a step has failed though we don't really have an idea what might be the issue.

With the usual steps we can just check the attached screenshots but as the pdf is never rendered we can't create a screenshot of it. Instead of rendering the pdf (right now we're just parsing it with pdfjs) I would like to attach the pdf to the report so I can download it and check for any issues after the run has finished.

✨ What's your proposed solution?

Allow PDFs as an attachment media type. Don't display it in the html report but offer a way to download the file (probably just a link to the base64 encoded buffer).

⛏ Have you considered any alternatives or workarounds?

I could try to render the pdf and attach each page as a single image.

πŸ“š Any additional context?


This text was originally generated from a template, then edited by hand. You can modify the template here.

davidjgoss commented 1 year ago

Thanks for raising @maxjoehnk.

Attaching the PDF to the test run will itself work okay:

await this.attach(buffer, 'application/pdf');

But this won't be rendered usably in our HTML report at the moment as you've hinted at. This is covered in https://github.com/cucumber/react-components/issues/80, so going to continue tracking that issue (which overs all language implementations). There may be a little work needed here once that’s done.

davidjgoss commented 1 year ago

Released in https://github.com/cucumber/cucumber-js/releases/tag/v9.3.0