[英]Test for pseudo class using Jest and React-test-renderer
I have a few hover pseudo classes in css and want to run a test and check if they are behaving properly. 我在CSS中有一些悬停伪类,并且想要运行测试并检查它们的行为是否正确。 Is this possible with Jest?
笑话有可能吗? Apologies for my lack of knowledge here I'm only a day in using Jest.
抱歉我缺乏知识,在这里我只用Jest一天。
Css: CSS:
.my-btn--lg.my-btn--brand.hover, .my-btn--md.my-btn--brand:hover {
background-color: #ac0000;
}
Seems it's impossible. 似乎不可能。
I'm not sure if jsdom provides appropriate version of window.getComputedStyle
but anyway there is no way to check for styles based on pseudoclass so far. 我不确定jsdom是否提供了适当版本的
window.getComputedStyle
但是到目前为止,仍然没有办法检查基于伪类的样式。 jest
as generic test runner and react-test-renderer
that "just" compiles JSX into HTMLElements knows nothing about pseudoclass/hover state. 作为通用测试运行程序和
react-test-renderer
jest
,“只是”将JSX编译为HTMLElements对伪类/悬停状态一无所知。
See also https://stackoverflow.com/a/11495671/2071697 for details how you can parse CSS by yourselves to find :hover
rule(but I believe it is not efficient way to compose unit tests) 另请参阅https://stackoverflow.com/a/11495671/2071697 ,了解如何自行解析CSS以查找
:hover
规则的详细信息(但我认为这不是编写单元测试的有效方法)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.