草庐IT

expection

全部标签

javascript - 为什么在使用 QUnit 编写测试时我会使用 expect()?

我最近开始使用QUnit对我的JavaScript进行单元测试,我对文档中的一个特性感到有点困惑:expect()。根据文档,expect()旨在:[s]pecifyhowmanyassertionsareexpectedtorunwithinatest.这是他们给出的例子:test("atest",function(){expect(2);functioncalc(x,operation){returnoperation(x);}varresult=calc(2,function(x){ok(true,"calc()callsoperationfunction");returnx*x

javascript - react .createElement : type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object

预计我应该能够导出我的App组件文件并将其导入到我的index.js中。结果出现以下错误React.createElement:typeisinvalid--expectedastring(forbuilt-incomponents)oraclass/function(forcompositecomponents)butgot:object我的index.jsconstReact=require('react');constReactDOM=require('react-dom');constApp=require('./components/App');require('./inde

javascript - 错误 : <rect> attribute width: Expected length, "NaN"。和 <text> 属性 dx : Expected length, "NaN"

我想在D3中实现一个条形图,但是我在dx轴上的值是Date类型,D3库应该接受的数据类型,但它似乎给我这样的错误:attributewidth:Expectedlength,“南”。这是我的代码:abargraph.axispath,.axisline{fill:none;stroke:black;shape-rendering:crispEdges;}.axistext{font-family:sans-serif;font-size:11px;}.MyRect{fill:steelblue;}.MyText{fill:white;text-anchor:middle;}varwid

javascript - Angular 7 "expected ' 样式'为字符串数组"

我正在尝试运行我的服务器并在localhost:8000上加载我的app.component.html。相反,我收到了这个错误compiler.js:7992UncaughtError:Expected'styles'tobeanarrayofstrings.atassertArrayOfStrings(compiler.js:7992)at>CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.j>s.CompileMetadataResolver.getNonNormalizedDi

javascript - 如何通过 expect.js async done() 出错的测试?

Mocha网站声明:“为了让事情变得更简单,done()回调接受一个错误,所以我们可以直接使用它:[参见他们的例子]”那么让我们试试看:it('works',function(done){expect(1).to.be(1)done(newError('expectederror'))})/*Inserttheerrormanuallyfortestingandclarity.*/运行它并:1failing1)works:Error:expectederroratContext.[stacktrace]当错误响应是期望的结果时,我们如何使测试通过? 最佳答案

javascript - ngAnnotate - 警告 : StringMap expected string key

我在使用Grunt和grunt-ng-annotate时收到此警告。警告中没有提到错误在文件中的位置,这使得调试变得困难。有什么想法吗? 最佳答案 问题原来是使用ES6符号,在本例中是箭头函数(=>)、默认参数和let。我没有详细了解为什么ngAnnotate不支持这个。为了找到问题出在哪里,我用gruntswitch--force覆盖了ngAnnotate警告,后来在构建uglify中提示了ES6语法的更多细节。 关于javascript-ngAnnotate-警告:StringMap

javascript - Angular 错误 : [filter:notarray] Expected array but received: {} with a filter on an ng-repeat

我正在尝试使用ng-repeat指令使用对API的Angular请求来填充html表。首先加载html页面,然后请求获取返回响应时填充表格的数据。当我向ng-repeat指令添加过滤器时,表格被填充并且过滤器起作用,但是在我的chrome浏览器控制台中,我收到以下错误:Error:[filter:notarray]Expectedarraybutreceived:{}http://errors.angularjs.org/1.4.3/filter/notarray?p0=%7B%7DatREGEX_STRING_REGEXP(angular.js:68)atangular.js:182

javascript - chai expect 函数是如何工作的?

从chai的api你有这样的代码:.existAssertsthatthetargetisneithernullnorundefined.varfoo='hi',bar=null,baz;expect(foo).to.exist;expect(bar).to.not.exist;expect(baz).to.not.exist;存在部分如何工作?expect函数返回一个对象,然后对“to”对象进行简单的属性查找。那只是一个属性评估,不是吗?唯一对我有意义的是exist属性是否是getter方法。怎么了? 最佳答案 chai公开了一个

javascript - expect() 没有实际期望

问题:最近,在审查我们现有的测试代码库时,我注意到在没有“匹配”部分的情况下使用expect()时出现了一种危险的打字错误:expect(page.filters.fromDateLabel.getText(),"After");我很确定toEqual()应该在这里使用:expect(page.filters.fromDateLabel.getText()).toEqual("After");这个问题是jasmine在这种情况下不会让预期失败(好吧,显然是因为实际上没有任何预期)。这让我们遇到了一个更严重的问题——在测试用例中实际上没有测试任何东西——它在没有期望的情况下通过了。我们对

JavaScript Ajax SCRIPT1003 : Expected ':' in IE 11

varurl="tabla.php";$.ajax({type:"POST",url:url,data:{place,names,repor},success:function(datos){$('#tabla').html(datos);}此代码在Chrome中有效,但在IE11中返回错误SCRIPT1003:Expected':'online5。非常感谢任何帮助。注意:place和names是之前定义的数组,repor也是之前定义的变量。 最佳答案 通常JavaScript中的对象被初始化为键值对,所以数据应该像这样初始化dat