草庐IT

Test_stub

全部标签

javascript - React TypeError this._test 不是一个函数

由于我是JavaScript和React的新手,我真的很难找出正确的语法。这是我的问题:_handleDrop(files)应该调用函数_validateXML(txt)但实际上没有。我收到此错误UncaughtTypeError:this._validateXMLisnotafunction并且无法弄清楚原因。回调_handleDrop(files)工作正常。当我尝试这种语法_validateXML:function(txt)时,我在编译时立即收到错误消息。是因为ecmascript吗?importReactfrom'react';import'./UploadXML.scss';i

javascript - 如何 stub require()/expect 调用模块的 "root"函数?

考虑以下jasmine规范:describe("something.act()",function(){it("callssomefunctionofmymodule",function(){varmod=require('my_module');spyOn(mod,"someFunction");something.act();expect(mod.someFunction).toHaveBeenCalled();});});这工作得很好。像这样让它变绿:something.act=function(){require('my_module').someFunction();};现在

javascript - Jasmine + AngularJS : How to test $rootScope. $broadcast 被调用参数?

我正在尝试编写一个单元测试来验证是否调用了$rootScope.$broadcast('myApiPlay',{action:'play'});。这是myapi.jsangular.module('myApp').factory('MyApi',function($rootScope){varapi={};api.play=function(){$rootScope.$broadcast('myApiPlay',{action:'play'});}returnapi;});这是我的单元测试:describe('Service:MyApi',function(){//loadtheser

javascript - Sinon.js - 在实例化组件之前 stub React 组件的功能?

假设我有一个如下所示的组件:varReact=require('react/addons');varExampleComponent=React.createClass({test:function(){returntrue;},render:function(){vartest=this.test();return(Testcomponent-{test});}});module.exports=ExampleComponent;在我的测试中,我可以使用TestUtils渲染这个组件,然后像这样stub方法:varrenderedComponent=TestUtils.renderI

javascript - sinon.js stub - 你能在一个 stub 函数上调用多个回调吗?

如果我有一个接受2个回调函数的stub,我如何连接sinon.js以在调用stub函数时调用两个回调?例如-这是我想要stub的函数,它接受2个函数作为参数:functionstubThisThing(one,two){...oneandtwoarefunctions......contentsstubbedbysinon.js...}我可以使用sinon来调用任一参数:stubbedThing.callsArg(0);或stubbedThing.callsArg(1);但我似乎无法让两者都被调用。如果我尝试:stubbedThing.callsArg(0).callsArg(1);或

JavaScript 正则表达式 : test and exec

我想获取多行文本中所有图像的URL(无论它包含什么)。这是我的代码:varpattern=/(http:\/\/\S+\.(?:jpg|gif|png|jpeg|JPG|GIF|PNG|JPEG))/mg;vartestResult=pattern.test(str));varresult=pattern.exec(str);如果str等于"http://example.dom.com/-6/x_5eb0916a.jpg",testResult等于true但result为null。为什么?你能帮我解决这个问题吗? 最佳答案 那是因为

unit-testing - 错误 : suite. go:61: test paniced: reflect: Call with too few input arguments

我正在golang中设置单元测试。但是现在我在运行gotest-v时遇到错误。我想解决这个错误并使测试成功。article├client├api│├main.go│├contoroller││├contoroller.go││└contoroller_test.go│├service││├service.go││└service_test.go│├dao││├dao.go││└dao_test.go│├s3││├s3.go││└s3_test.go│├go.mod│├go.sum│└Dockerfile├nginx└docker-compose.yml现在我正在为service.go设

Golang 项目 Travis CI Build 失败,错误为 `Makefile:15: recipe for target ' test' failed`

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。这个问题似乎与helpcenter中定义的范围内的编程无关。.关闭3年前。Improvethisquestion我已经为我的Github项目设置了travisbuildCaptain.travis.yml的内容是:language:gogo:-1.12.xscript:makeenv:-GO111MODULE=onGOPROXY=https://proxy.golang.org我的Makefile的内容是:#GoparametersBINARY_FOLDER=./binGOCMD=goGOBUILD=

go test 错过了执行路径上的覆盖

考虑这样的文件结构:api--|_routes.go|_handler.goimpl--|_impl.go|_impl_test.go“impl”文件包含RESTAPI的内部实现,其处理程序和路由分别位于“handler.go”和“route.go”文件中。就打包而言,“api”文件夹下的所有内容都在“api”包中。“impl.go”中的代码在“impl”包中,“impl_test”包中的代码在“impl_test”包中。api-------|_routes|_handlerfunctionsimpl-------|_implfunctionsimpl_test--|_testfunc

go - vendor 问题 : found packages text (doc. 去)和转换(examples_test.go)在我的 vendor

这个问题在这里已经有了答案:Error"can'tloadpackage:packagemy_prog:foundpackagesmy_progandmain"(3个答案)关闭4年前。我遇到了一些问题:enterimagedescriptionhere..\vendor\github.com\spf13\afero\util.go:28:2:在D:\golang\src\services\vendor中找到包文本(doc.go)和转换(examples_test.go)\golang.org\x\text\transform我该如何解决这个问题?谢谢。