Let's say you just received the requirement about implementing a new feature in your webapp which should print on paper a section of that page. The requirement talks about optional elements to be part or not of the printed product.
What is the best possible way of testing this feature automatically? I am aware that once you invoke the printing command that's out of the Browsers' scope so it's not possible to write a perfect automated test so the question is oriented to find the best "good enough" approach, hopefully something better than only spying on window.print() to assert it was called.
There's an emulation mode in Chrome, see using-chromes-element-inspector-in-print-preview-mode.
You can turn it on with Cypress, see Using Chrome Debugger Protocol from Cypress.
HTML
Example test