草庐IT

jest-jasmine

全部标签

javascript - 如何在 Visual Studio Code 中调试从 Grunt 运行的 Jasmine 测试?

我的单元测试是通过Grunt使用Karma/Jasmine运行的。当我运行时grunttest测试从命令行执行。在VisualStudioCode中打开项目时,我可以使用Tasks:RunTestTask运行相同的命令。VSCode使用test参数执行Grunt并显示输出。在这种情况下如何调试VSCode运行的测试用例?当我按下F5时,会打开launch.json模板文件。我需要为program、args等提供什么来启动/调试由grunttest运行的相同测试用例?我尝试了以下方法:程序:/usr/local/bin/gruntargs:["test"]这成功启动了Grunt进程并执行

javascript - 如何在 Visual Studio Code 中调试从 Grunt 运行的 Jasmine 测试?

我的单元测试是通过Grunt使用Karma/Jasmine运行的。当我运行时grunttest测试从命令行执行。在VisualStudioCode中打开项目时,我可以使用Tasks:RunTestTask运行相同的命令。VSCode使用test参数执行Grunt并显示输出。在这种情况下如何调试VSCode运行的测试用例?当我按下F5时,会打开launch.json模板文件。我需要为program、args等提供什么来启动/调试由grunttest运行的相同测试用例?我尝试了以下方法:程序:/usr/local/bin/gruntargs:["test"]这成功启动了Grunt进程并执行

javascript - Jest 循环遍历动态测试用例

如何在Jest中循环遍历动态测试用例?我有如下测试用例,如何使用it/test方法动态创建jest测试用例。这是我尝试过的,但是它只是通过而没有执行循环中的测试用例。constmymodule=require('mymodule');consttestCases=[{q:[2,3],r:5},{q:[1,2],r:3},{q:[7,0],r:7},{q:[4,4],r:8}];describe("TestmyMathmodule",()=>{test("testaddmethod",()=>{for(leti=0;i{constactual=mymodule.add(q[0]+q[1]

javascript - Jest 循环遍历动态测试用例

如何在Jest中循环遍历动态测试用例?我有如下测试用例,如何使用it/test方法动态创建jest测试用例。这是我尝试过的,但是它只是通过而没有执行循环中的测试用例。constmymodule=require('mymodule');consttestCases=[{q:[2,3],r:5},{q:[1,2],r:3},{q:[7,0],r:7},{q:[4,4],r:8}];describe("TestmyMathmodule",()=>{test("testaddmethod",()=>{for(leti=0;i{constactual=mymodule.add(q[0]+q[1]

javascript - Jasmine Node 说 "0 tests"当有*有*测试

我希望这会说“1次测试”,但它会说“0次测试”。知道为什么吗?这是在OSX上。$jasmine-node--verbosemy.spec.jsundefinedFinishedin0.001seconds0tests,0assertions,0failures,0skipped$catmy.spec.jsdescribe("bar",function(){it("works",function(){expect("foo").toEqual("foo");});});$jasmine-node--version1.11.0$npm--version1.3.5$node-vv0.4.12

javascript - Jasmine Node 说 "0 tests"当有*有*测试

我希望这会说“1次测试”,但它会说“0次测试”。知道为什么吗?这是在OSX上。$jasmine-node--verbosemy.spec.jsundefinedFinishedin0.001seconds0tests,0assertions,0failures,0skipped$catmy.spec.jsdescribe("bar",function(){it("works",function(){expect("foo").toEqual("foo");});});$jasmine-node--version1.11.0$npm--version1.3.5$node-vv0.4.12

node.js - Jasmine (mocha) 嵌套 "it"测试

我试图测试项目的后续创建/删除(在mongoDB中通过mongoose)。创建是异步的问题,它在回调函数中返回创建项目的ID,我需要这个ID来删除创建的项目,所以我尝试了以下mocha代码(以不同的方式)但它没有工作。describe('ItemModel',function(){it('shouldbeabletocreateitem',function(done){varitem=newItem({name:{first:"Alex"});item.save(function(err,data){it('shouldbeabletodeletedcreateditem',funct

node.js - Jasmine (mocha) 嵌套 "it"测试

我试图测试项目的后续创建/删除(在mongoDB中通过mongoose)。创建是异步的问题,它在回调函数中返回创建项目的ID,我需要这个ID来删除创建的项目,所以我尝试了以下mocha代码(以不同的方式)但它没有工作。describe('ItemModel',function(){it('shouldbeabletocreateitem',function(done){varitem=newItem({name:{first:"Alex"});item.save(function(err,data){it('shouldbeabletodeletedcreateditem',funct

javascript - 模拟依赖的构造函数 Jest

我是Jest的新手。我设法模拟了我自己的东西,但似乎一直在模拟一个模块。特别是构造函数。用法.jsconstAWS=require("aws-sdk")cw=newAWS.CloudWatch({apiVersion:"2010-08-01"})...functionmyMetrics(params){cw.putMetricData(params,function(err,data){})}我想在测试中做这样的事情。constAWS=jest.mock("aws-sdk")classFakeMetrics{constructor(){}putMetricData(foo,callba

javascript - 模拟依赖的构造函数 Jest

我是Jest的新手。我设法模拟了我自己的东西,但似乎一直在模拟一个模块。特别是构造函数。用法.jsconstAWS=require("aws-sdk")cw=newAWS.CloudWatch({apiVersion:"2010-08-01"})...functionmyMetrics(params){cw.putMetricData(params,function(err,data){})}我想在测试中做这样的事情。constAWS=jest.mock("aws-sdk")classFakeMetrics{constructor(){}putMetricData(foo,callba