Tag: 茉莉花

茉莉花testing通过竹子?

我想将茉莉花testing与竹子结合起来,但我不确定是否可能。 到目前为止,我发现的最好的是https://bitbucket.org/atlassian/bamboo-nodejs-plugin ,它只支持摩卡testing。 我想知道有没有办法改变节点茉莉花输出与竹兼容。 谢谢

量angular器:正确使用我的testing中的waitReady.js文件

我们在整个testing套件中广泛使用browser.wait。 pipe理不同场景的不同超时时,它变得头痛。 我遇到了一个waitReady函数( https://gist.github.com/elgalu/2939aad2b2e31418c1bb ),但我无法在我的代码中使用它。 该目录看起来像:(所有文件除了彼此)。 ├── conf.js ├── main.js ├── waitReady.js Main.js —>包含所有的描述和它的块 require('./waitReady.js'); describe(…){ it{ code… expect(element.waitReady()).toBeTruthy(); }; }); 出于某种原因,代码没有find该函数,我的代码不断收到函数未定义的错误。 我需要在什么地方初始化它吗?

茉莉花节点 – 包括帮手

我试图用茉莉花节点来testing我的Meteor应用程序。 我在助手( spec_helper.js )中列出了一些Meteor框架的方法: var Meteor = { startup: function (newStartupFunction) { Meteor.startup = newStartupFunction; }, Collection: function (collectionName) { Meteor.instantiationCounts[collectionName] = Meteor.instantiationCounts[collectionName] ? Meteor.instantiationCounts[collectionName] + 1 : 1; }, instantiationCounts: {} }; 在这一点上,我需要在spec_helper.js中运行代码(相当于包含其他语言的模块)。 我试过以下,但没有成功: require(['spec_helper'], function (helper) { console.log(helper); // undefined describe('Testing', function () { it('should test Meteor', function () { // that's what […]

茉莉花链testing

我正在使用茉莉花来testing我的项目。 我用它来进行集成testing,而不是unit testing。 describe("admin", function () { var testUser = { name: 'test', pass: 'pass' }; it("should be able to create a new user", function(done) { needle.post(server + "addUser.php", testUser, function (err, res) { expect(res.statusCode).toBe(200); done(); }); }); it("should be able to delete the user", function(done) { needle.post(server + "deletedUser.php", testUser, function (err, res) { […]

我怎么能得到伊斯坦布尔与节点,摩卡,茉莉花和js要求

我有一个现有的testing套件,使用mocha,require和jasmine在node.js中正常运行,testing通过psake powershell脚本运行。 我正在尝试添加testing覆盖率,所以要运行unit testing而不是: 节点unitTest.js 我在做 伊斯坦布尔封面unitTest.js 这似乎工作,但只给了我关于unitTest.js本身的覆盖范围信息,但没有在项目中使用任何其他实际的JavaScript文件。 我猜这是因为要求/摩卡的组合,所以它不知道我使用的js文件。 我尝试手动将所有文件作为代码覆盖之前的一个步骤,并在复制/检测的文件上运行相同的命令,但得到相同的结果。 有关使这项工作的任何提示? 这是unitTest.js的最后一部分 requirejs(['mocha'], function(Mocha) { var mocha = new Mocha({reporter: (process.env['TEAMCITY_VERSION'] ? 'teamcity' : 'spec')}); // Hack to establish the global variables (sigh) mocha.suite.emit('pre-require', global, __filename, mocha); fswalk(__dirname, function(err, results) { if (err) console.warn(err); else { var testName = process.argv[2] || ""; console.log("testName: " + […]

通过幻影运行茉莉花规格,得到“无法findvariables:描述”

当我在CI作业上运行在centOS5 linux服务器上时,遇到了同样的问题,用phantomJS 1.7(我自己编译) Running "jasmine" task Testing jasmine specs via phantom … [D] ["phantomjs","onResourceReceived","GET http://127.0.0.1:8888/test/spec/CommonTest.js"] [D] ["phantomjs","onError","ReferenceError: Can't find variable: describe", [{"file":"http://127.0.0.1:8888/test/spec/CommonTest.js","line":31,"function":""}]] ReferenceError: Can't find variable: describe … 在其他机器,如WinXP等规格运行成功

使用jasmine.spyOn用于mongoose模式方法

我无法让茉莉间谍为我的mongoose文件工作。 我有一个方法设置在我的用户架构像这样: User.methods.doSomething = function() { // implementation } 用户是我正在testing的模型的依赖关系,我想确保doSomething被正确调用。 在我的testing中,我有这样的东西: spyOn(User.schema.methods, 'doSomething') 如果我注销User.schema.methods.doSomething我得到我期望的function,但是当我运行调用该方法的代码原始实现被调用,而不是间谍。 我也不能这样做: spyOn(userInstance, 'doSomething') 在我的testing中,userInstance没有被暴露,我真的想避免暴露它。 本质上,我想在用户文档(实例?)原型上设置一个间谍。 那可能吗?

如何使用茉莉花和节点从命令行testingjQuery插件?

我有我正在testing的jQuery插件。 我发现这个问题: 如何从命令行上运行JasminetestingNode.js? 但是当我运行: node_modules/jasmine-node/bin/jasmine-node –verbose –junitreport –noColor spec 我得到错误,没有定义$。 我如何包含jQuery? (现在我只testing不与dom交互的实用程序)。

承诺解决后调用函数,但Jasmine不通过testing。 为什么?

我的应用程序使用一个服务,返回一个通常依赖于一大堆其他承诺的承诺。 我已经将这个重构成单独的命名函数,使testing(和可读性)更容易。 所以在这种情况下,我只想testing一下run函数是否完成了它的工作并调用其他函数。 例如 run() { return myService .connection .then(this.namedFunction1) .then(this.namedFunction2) .then(this.namedFunction3) .catch((error) => { console.log("doh!", error.stack); }); 当我testingnamedFunction1被称为茉莉花失败时,尽pipe事实并非如此。 下面是我为保持简单而编写的一个小代码示例: getString() { return Promise.resolve("Heeeelp. Heeeelp!!"); } printToConsole(string) { console.log(string); // This works! but Jasmine says nay 🙁 } myFunction() { this.getString() .then(this.printToConsole) .catch((error) => { console.log("Some error occurred", error); }); } …和testing: it("should call the […]

使用jasmine和node.jstestingweb API

我们编写了一个RESTful Web API,它使用node.js响应GET和PUT请求。 我们在testingAPI时遇到一些困难。 首先,我们使用了Zombie.js ,但没有很好的logging,所以我们无法得到PUT请求: var zombie = require("zombie"); describe("description", function() { it("description", function() { zombie.visit("http://localhost:3000/", function (err, browser, status) { expect(browser.text).toEqual("A") }); }); }); 之后,我们尝试使用一个名为restler的REST客户端,这可以,因为我们不需要任何高级的浏览器模拟。 这是因为请求似乎是asynchronous的,即testing是无用的,因为它在调用“成功”callback之前完成了: var rest = require('restler'); describe("description", function() { it("description", function() { rest.get("http://www.google.com").on('complete', function(data, response) { // Should fail expect(data).toMatch(/apa/i); }); }); }); 我们将感谢有关替代testing框架或同步请求客户端的任何提示。