问题
can we emulate print mode (media query print) for unit testing? (Ract, enzyme, jest) i try:
window.matchMedia('print')
but it does not work for me, style media print not applied;
回答1:
I use iframe for printing and added some param to url for that. We can test printing using thit param:
window.location.hash = '?printMode=true'; // my variant
after that run component and lets try to write tests.
来源:https://stackoverflow.com/questions/47219643/can-we-emulate-print-mode-media-query-print-for-unit-testing