草庐IT

laravel-testing

全部标签

javascript - 如何在规范文件中注入(inject)服务 Angular Testing (Jasmine/karma)

我刚开始编写Angular单元测试用例。我在我的Controller文件(.ts)中注入(inject)一项服务。我将如何在规范文件中注入(inject)服务文件。代码如下:app.component.tsgetSortData(){this.sortService.sortNumberData(this.data,'name','asce');}sort.service.tssortNumberData(data,rendererKey,type){//data.sort((elem1,elem2)=>{////ifnumberisundefined,thenassigning`MA

javascript - '错误 : Unexpected request' during Karma Angular Unit Test

运行gruntkarma时,其中一个指令的测试在尝试获取模板时失败。我使用ng-html2js作为预处理器。这是我的一些karma.conf.jsplugins:['karma-chrome-launcher','karma-jasmine','ng-html2js','karma-ng-html2js-preprocessor'],preprocessors:{'app/scripts/directives/**/*.html':'ng-html2js'},ngHtml2JsPreprocessor:{moduleName:'templates'}在我的测试中,我有以下内容:'use

laravel 中的 Javascript 函数未定义

我在我的app.js中添加了一个js方法:require('./bootstrap');window.Vue=require('vue');Vue.component('example',require('./components/Example.vue'));constapp=newVue({el:'#app'});functionhello(){alert("hello");}然后编译我的资源并将app.js添加到我的View中:如果此时加载我的View并查看源代码,我可以看到指向app.js的链接,如果我打开该app.js,我可以在其中看到我的hello方法以及许多其他内容。现在

javascript - 使用 Jest 时防止 "test/expect/etc is not defined"错误

Facebook的Jest测试框架很容易getstartedwith,butthedocumentation俯瞰一个annoyingaspect:任何试图警告undefinedsymbol的编辑器都会将测试语句突出显示为错误,因为未定义test、expect和所有匹配器方法。同样,尝试直接使用node运行测试文件将失败并显示ReferenceError:testisnotdefined。需要添加哪些require/import语句才能消除这些错误? 最佳答案 节点如果您想直接通过节点运行它们,请尝试要求jest和/或jest-run

javascript - RegExp.test 不工作?

我试图在javascript中使用Regex.test验证年份,但无法弄清楚为什么它返回false。varregEx=newRegExp("^(19|20)[\d]{2,2}$");regEx.test(inputValue)对于输入值1981、2007返回false谢谢 最佳答案 当您使用字符串表达式创建RegExp对象时,您需要加倍反斜杠以便它们正确转义。另外[\d]{2,2}可以简化为\d\d:varregEx=newRegExp("^(19|20)\\d\\d$");或者更好的是使用正则表达式文字来避免双反斜杠:varreg

javascript - Laravel 5 扩展 Elixir 以包含 browserify

我的browserify工作流程(从coffee到js,使用browserify-shim和coffeeify)是这样的:我有2个主要文件,app.coffee和_app.coffee,分别用于前端和后端。这两个文件分别位于resources/coffee/front和resources/coffee/back中。我正在尝试在laravelelixir中包含browserify任务,因此结果文件将位于public/js/app.js和public/js/_app.js并且稍后可以修改到build文件夹。到目前为止,我已经尝试通过在elixir的node_modulesingredien

javascript - meteor JS : How to stub validated method in unit test

我正在使用经过验证的方法(mdg:validated-method)和LoggedInMixin(tunifight:loggedin-mixin)。现在我的单元测试出现了问题,因为它们因notLogged错误而失败,因为在单元测试中当然没有登录用户。我怎么必须stub呢?方法constresetEdit=newValidatedMethod({name:'reset',mixins:[LoggedInMixin],checkLoggedInError:{error:'notLogged'},//单元测试describe('resetEdit',()=>{it('shouldreset

javascript - 如何从 jqgrid 和 Laravel 上传多个文件?

下面是我的代码:letcolNames=['ID','Image','Title','Description'];letcolModel=[{name:'id',index:'id',width:30,editable:true,editoptions:{size:"30",maxlength:"50"}},{name:'image',index:'image',align:'left',editable:true,edittype:'file',editoptions:{multiple:true,accept:".jpg,.png,.jpeg",enctype:"multipart

javascript - 在另一个项目中使用 marble testing rxjs5 方法

我有一个webapp项目,它使用rxjs5来实现flux我目前正在寻找为其编写单元测试的解决方案。其实我已经在里面实现了自定义的observables,例如:functiongetActivityObservable(events,timeout){returnObservable.create((observer)=>{constdeb=debounce(()=>observer.next(false),timeout||DEFAULT_TIMEOUT);constsub=events.subscribe((e)=>{if(!e){deb.cancel();observer.next

javascript - 带有异步 forEach 循环的磁带 "test exited without ending"错误

我在做什么编辑:我创建了一个repo使用我的问题的简化版本重现问题。我正在尝试使用browserstack设置自动化前端测试,selenium-webdriver和tape.Moreabouttape这个想法是定义多个浏览器和设备,这些浏览器和设备必须用X数量的给定测试一个接一个地进行测试。在下面的例子中,我在OSX上只定义了一个测试和两个浏览器。为了只定义一次浏览器并处理测试,我创建了一个repotest-runner,它应该作为dev-dependency添加到需要的repos在给定的设备和浏览器上测试。test-runner使所有需要的测试都通过,启动第一个浏览器,在该浏览器上运