can we emulate print mode (media query print) for

2019-03-06 10:32发布

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条回答
小情绪 Triste *
2楼-- · 2019-03-06 11:22

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.

查看更多
登录 后发表回答