jjzjj

test-utils

全部标签

javascript - 脚本运行时 Heroku 日志警告 "(node) sys is deprecated. Use util instead"

我已经在heroku中部署了一个由调度程序运行的Node脚本。但是当脚本运行时,我在日志中看到一条警告。Dec0711:01:10xxxheroku/scheduler.3255Startingprocesswithcommand`nodebin/script`Dec0711:01:13xxxapp/scheduler.3255:(node)sysisdeprecated.Useutilinstead.我还没有在我的package.json中声明一个engine部分。是不是node版本有问题?我怎样才能避免这个警告?谢谢! 最佳答案

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 - 如何在规范文件中注入(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

javascript - ko.utils.arrayMap,但只返回数组的一部分

我正在使用此处精彩描述的一些Knockout实用函数:http://www.knockmeout.net/2011/04/utility-functions-in-knockoutjs.html我想做一个arrayMap来根据条件选择某些属性,例如returnko.utils.arrayMap(myObservableArray(),function(item){returnitem.Label;});例如,这会产生以下输出:[null,"","SomeLabel",null,"SomeOtherLabel"]我想根据条件选择属性,所以我尝试:returnko.utils.arrayM

JavaScript:是否有 utils 库?

按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭9年前。我想知道是否存在这样的库,该库仅包含一组常用实用函数,例如trim、indexOf(用于数组)、map,each,typeOf等等...我知道jQuery提供了我上面列出的一些功能,但我正在寻找纯粹为此设计的东西(例如,我真的不需要在服务器端运行node.js的jQuery,如果我正在编写一个与jQuery无关的JavaScript库,我也不想依赖它)。我

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

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