草庐IT

run-jasmine

全部标签

javascript - Angular Karma Jasmine - 测试功能

基本上我必须测试下面这个函数,我正在从文本文件中读取$window.resolveLocalFileSystemURL(cordova.file.dataDirectory,function(dir){varpath='somefile.txt';dir.getFile(path,{create:true},function(file){file.file(function(file){varreader=newFileReader();reader.onloadend=function(){resolve(this.result);}reader.readAsText(file);}

javascript - 错误 : "Cannot find module" while running firebase cloud function

constfunctions=require('firebase-functions');varnodemailer=require('nodemailer');//constexpress=require('express');vartransporter=nodemailer.createTransport('smtps://username@gmail.com:password5@smtp.gmail.com');exports.sendMail=functions.https.onRequest((req,res)=>{varmailOptions={to:'receiver@

javascript - Jasmine : Timeout - Async callback was not invoked within timeout

我需要测试一个从url加载图像的AngularJs服务。这是我的服务:/*globalangular,Image*/(function(){'usestrict';functionSourceLoader($q,$log){/***Loadanimagefromurlandreturnapromisewhichisresolvedwhenimageisloadingisdone.*Itreturntheimagesobjectasresolvedpromise.*@paramurlsourceoftheimage*@returns{Promise}unresolvedpromiseof

javascript - 使用 Jasmine 或任何其他替代方案在 Node 上运行测试 .mjs/ESM

由于--experimental-modulesCLI开关(即node--experimental-modules),我的基于Node的项目是在Node上使用原生ES模块支持实现的.显然,当我使用Jasminenode--experimental-modules./node_modules/jasmine/bin/jasmine运行规范时,出现以下错误:Error[ERR_REQUIRE_ESM]:MustuseimporttoloadESModule是否可以在Node中通过ES模块使用Jasmine?如果不是,是否有任何替代方法不使用框架(例如,使用npm脚本运行测试)?

javascript - 为什么 npm react-scripts 在我运行 `npm run start` 时会产生语法错误?

这个问题在这里已经有了答案:SyntaxError:missing)afterargumentlist,Whenusingasync(3个答案)关闭3年前。所以我已经在全栈React应用程序上工作了几个月。出于某种原因,当我尝试在命令行上运行npmrunstart时,似乎不知何故,它产生了以下错误;//npmrunstart>pair@0.1.0start/Users/eden/Documents/GitHub/Pair./pair>react-scriptsstart/Users/eden/Documents/GitHub/Pair./pair/node_modules/react-

javascript - jQuery run 函数 onload 和 key up

我有以下内容,我想在页面加载时第一次运行。然后我希望它在用户进行更改时在keyup上运行。我想运行的函数非常大(为了在此处发布而被删除)所以我不想复制该函数。有没有办法调用函数onload然后在keyup上重用它?谢谢$(document).ready(function(){//thiscalculatesthesumforsometextnodes$("td,input").keyup(function(){varcol_1revenue=$(".Col1Receipts,.Col1Receiptsinput").sum();}//function);//keyup});//docu

javascript - 使用 jasmine 进行 jquery 测试

我是Jasmine的初学者。我不知道如何使用jasmine测试以下jquery代码。if($('.data-block').length>0){$('.span4:even','.data-block').addClass('even');$('.span4:odd','.data-block').addClass('odd');}你能告诉我如何使用jasmine为这个jquery程序编写测试代码吗?谢谢你的回答。 最佳答案 您可以使用Jasmine-JQuery插件并针对注入(inject)的DOM进行测试:https://git

javascript - 预期 '> ' 等于 Jasmine 中的 '> '

我正在测试jQuery终端,但出现错误:Expected'>'toequal'>'.测试时:$(function(){describe('Terminalplugin',function(){describe('terminalcreateterminaldestroy',function(){varterm=$('').appendTo('body').terminal();it('shouldhavedefaultprompt',function(){varprompt=term.find('.prompt');expect(prompt.html()).toEqual(">

javascript - Jasmine toBeCloseTo 第二个参数是什么?

Jasmine的文档非常简短;通常就足够了。不总是。我想知道toBeCloseTo的第二个参数到底是什么。官方引用仅显示:it("The'toBeCloseTo'matcherisforprecisionmathcomparison",function(){varpi=3.1415926,e=2.78;expect(pi).not.toBeCloseTo(e,2);expect(pi).toBeCloseTo(e,0);});好的,这是精确度,但在这种情况下,“精确度”的实际含义是什么?是“.”后面的位数吗?那应该是一样的吧?我的情况:我想以毫秒为单位比较两个时间戳;如果它们之间的差异

javascript - 当我在 React 应用程序上执行 npm start 时,不断收到 "? Something is already running on port 3000"

当我启动我的react服务器时,我的终端中不断收到“?端口3000上已经有东西正在运行”消息,而我的端口3000上绝对没有任何东西正在运行我试图解决的问题:重新启动macOS。在chrome浏览器上检查我的“http://localhost:3000”。(无:无法访问此站点)转到chrome://serviceworker-internals和chrome://appcache-internals,搜索localhost:3000(未找到)我还尝试了几乎所有在Google上找到的与此问题相关的命令行我还创建了另一个express.js应用程序,它在端口3000上成功启动,而React说