草庐IT

TESTNG_TEST_TIMEOUT

全部标签

javascript - Regex.test() 给出真假顺序?

任何人都可以解释一下,为什么本地Regex变量和非本地Regex变量有不同的输出。varregex1=/a|b/g;functionisAB1(){returnregex1.test('a');}console.log(isAB1());//trueconsole.log(isAB1());//falseconsole.log(isAB1());//trueconsole.log(isAB1());//falsefunctionisAB2(){varregex2=/a|b/g;returnregex2.test('a');}console.log(isAB2());//truecons

javascript - 使用 Chutzpah 运行 QUnit (TypeScript) 测试给出 "Called start() outside of a test context while already started"

我有一个相当简单的重现,结果我不明白。确保安装了Chutpah测试适配器4.0.3。使用VisualStudio2013执行以下步骤:创建一个新的.NET4.5.1类库项目;添加NuGet包qunit.TypeScript.DefinitelyTyped0.1.7;将TypeScript文件file1.ts添加到项目中,内容如下:///QUnit.test("QUnitisworking",assert=>assert.ok(true));在该文件内右键单击并从上下文菜单中选择“运行JS测试”。我可以确认file1.js是按预期生成的。结果是没有运行任何测试,测试资源管理器没有显示测试

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

javascript - 类型错误 : $timeout is not a function

这里发生了什么:我希望“取消预订”按钮在单击后超时。第一次单击时,它会更改为显示“确认取消”按钮。几秒钟后返回“取消预订”。我的控制台给我:TypeError:$timeoutisnotafunction我正在使用AngularJS$timeout:Controller:'usestrict';module.controller('ReservationItemCtrl',['$scope','$stateParams','$RPC',function($scope,$stateParams,$RPC,$timeout){......otherstuff.............oth

javascript - AngularJS - 仅在 ng-change 上触发 $timeout 事件一次

我在绑定(bind)到范围变量的html输入字段上有一个ng-change。varchange=function(){redraw_graph()}现在,当我更改输入框时,它会为我输入的每个新字符重新绘制图形。我想要延迟(N秒),所以在ng-change事件触发之前,angular会等待用户完成输入。如果触发了多个ng-change事件,它会取消较早的事件,只执行最新的事件。我已将延迟与超时结合起来,但在N秒后,ng-change事件仍然触发不止一次。我以前解决过这个问题,但我目前不知道该怎么做。 最佳答案 对我来说,您所要求的似乎

javascript - $timeout 函数中的 AngularJS 'this' 引用不起作用

我有一个让我发疯的AngularJS问题。我有一个看起来像这样的服务(这是一个说明问题的例子)varapp=angular.module('test-module');app.service('ToolService',function($timeout){this.doSomething=function(){console.log("yunoreferencedasmethod?!?");}this.runTimeoutExample=function(){$timeout(function(){this.doSomething();},1000);}})我的Controller看

javascript - jasmine.clock().tick() 不适用于 $timeout 和 debounce,但适用于 setTimeout

下面我有3个功能完全相同。每种调用setTimeout的方式不同,delay1()直接使用setTimeout,delay2()使用angularjs$timeout和delay3()使用lodashdebounce。它们都工作正常。问题出现在我用Jasmine测试的时候。setTimeout可以与jasmine.clock().tick()方法配合使用,但$timeout和debounce不适用't我有兴趣使用Jasmine进行去抖动。我知道我可以将$timeout.flush()与angularjs一起使用,但是$timeout和setTimeout在我使用的代码的其他地方给我带来

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 - 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