我无法使用fireClick.mouseOver(tab)
标签上的悬停测试工具提示。
下面是代码段。
it('should handle change on hover of tab', () => {
const {getByTestId, getByRole} = renderComponent('Draft');
const tab0 = getByTestId('tab-0');
fireEvent.mouseOver(tab0);
expect(getByRole('tooltip')).not.toBeNull();
}
我收到的异常是“ document.createRange is not a function
”
但是fireEvent.click(tab)
运作良好。
答案 0 :(得分:0)
您可能会收到此错误的原因是因为在DOM中找不到<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>3.26.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-swagger</artifactId>
<version>3.3.2</version>
</dependency>
@Configuration
public class RestServerConfig {
@Bean
@Autowired
public Server jaxRsServer(ApplicationContext context) {
SpringJAXRSServerFactoryBean factory = RestServerFactory.withELHDefaultConfig(context);
//Swagger Settings
Swagger2Feature feature = new Swagger2Feature();
feature.setBasePath("/");
feature.setScan(true);
feature.setScanAllResources(true);
feature.setTitle("Rest API");
feature.setVersion("3.0.0");
feature.setDescription("API for ELH Rest Server");
feature.setResourcePackage( "com.rest.api");
factory.getFeatures().add(feature);
factory.setAddress("/");
return factory.create();
}
,这意味着HTML节点不存在或属性role="tooltip"
不存在。
如果存在,则将玩笑更新为26+
例如:role
应该可以解决问题