Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.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
Unit testing 无法比较karma/jasmine/PhantomJS测试中的HTML字符串,因为图标错误_Unit Testing_Phantomjs_Karma Jasmine - Fatal编程技术网

Unit testing 无法比较karma/jasmine/PhantomJS测试中的HTML字符串,因为图标错误

Unit testing 无法比较karma/jasmine/PhantomJS测试中的HTML字符串,因为图标错误,unit-testing,phantomjs,karma-jasmine,Unit Testing,Phantomjs,Karma Jasmine,我有一个测试,它(应该)检查我的工厂呈现的元素html是否正确。然而,这个元素包含材质图标,在这个测试中似乎不可能比较它的HTML 简化测试用例: describe( 'Compile: ', function () { it( 'compare two html strings and should be equal', function () { var mockEl = $( '<i class="material-icons">&#xE24B;</i

我有一个测试,它(应该)检查我的工厂呈现的元素html是否正确。然而,这个元素包含材质图标,在这个测试中似乎不可能比较它的HTML

简化测试用例:

describe( 'Compile: ', function () {
  it( 'compare two html strings and should be equal', function () {
    var mockEl = $( '<i class="material-icons">&#xE24B;</i>' )
      ;
    expect( mockEl[0].outerHTML ).toBe(
      '<i class="material-icons">&#xE24B;</i>'
    );    
  } );
} );
description('Compile:',函数(){
它('比较两个html字符串并应相等',函数(){
var mockEl=$(';')
;
预期(mockEl[0].outerHTML.toBe(
“;”
);    
} );
} );
在结果I中,测试抛出错误:

Expected <i class="material-icons"></i>' to be '<i class="material-icons">&#xE24B;</i>'.
应为' 为“;”。
这是Chrome控制台中图标jQuery对象
文本
的外观:


尝试使用unicode值进行比较,如下所示

expect( mockEl[0].outerHTML ).toBe(
  '<i class="material-icons">\ue24b</i>'
);
expect(mockEl[0].outerHTML).toBe(
“\ue24b”
);