Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 使用酶获得HTMLElement_Reactjs_Typescript_Jestjs_Enzyme - Fatal编程技术网

Reactjs 使用酶获得HTMLElement

Reactjs 使用酶获得HTMLElement,reactjs,typescript,jestjs,enzyme,Reactjs,Typescript,Jestjs,Enzyme,下面是我想用jest和Ezyme测试的函数: const getTotalValue=(list:string[],element:HTMLElement):number=>list .map((prop:string)=>element?parseInt(对象(window.getComputedStyle(element))[prop],10):0) .reduce((prev,cur)=>prev++cur,0); 以下是我尝试测试它的方式: description('getTotalV

下面是我想用jest和Ezyme测试的函数:

const getTotalValue=(list:string[],element:HTMLElement):number=>list
.map((prop:string)=>element?parseInt(对象(window.getComputedStyle(element))[prop],10):0)
.reduce((prev,cur)=>prev++cur,0);
以下是我尝试测试它的方式:

description('getTotalValue',()=>{
它('返回一个数字',()=>{
常量属性:字符串[]=['高度','宽度'];
常数包装=安装(测试);
expect(getTotalValue(properties,wrapper.instance()).not.toBeNaN();
});
});
当我执行
wrapper.instance()
时,测试正在通过,但我在编译时遇到以下错误:

Argument of type 'Component<{}, {}, any>' is not assignable to parameter of type 'HTMLElement'.
类型为“Component”的参数不能分配给类型为“HTMLElement”的参数。
我知道这是一个打字错误。但我想知道如何使用酶获得HTMLElement