Tag: 茉莉花

为什么在`jasmine init`和`jasmine examples`之后运行`jasmine`什么都不做?

我已经通过运行npm install jasmine -g全局安装了jasmine。 运行jasmine -v给我 jasmine v2.5.0 jasmine-core v2.5.0 那么按照文档 ,我就运行了 jasmine init jasmine examples 这创build了预期的/spec目录和spec/support/jasmine.json文件。 我的印象是,如果我现在运行jasmine我应该在控制台中看到一些testing输出。 相反,它只是想一秒钟,然后什么都不做。 我在Git Bashterminal的Windows 7机器上运行node v4.5.0。 我已经尝试从Windows cmd提示符运行它,但也不起作用。

什么是从节点使用茉莉花的正确方法?

经过多次黑客攻击之后,我设法通过Node运行一个简单的Jasminetesting。 然而,有一些奇怪的东西,我不明白…茉莉花文件出口函数似乎需要一个引用自己传回去工作(这是茉莉花和ConsoleReporter)。 我敢肯定,这不是正确的方法来做到这一点(虽然我很高兴,我终于做了一些testing运行:)),所以有人可以解释更好的方法来做到这一点? (注意:我不想吸引更多的第三方代码,我不明白像茉莉花;我想明白我现在有什么;不添加更多!) // Include stuff jasmine = require('../../../Apps/Jasmine/jasmine-standalone-2.0.0/lib/jasmine-2.0.0/jasmine.js'); jasmineConsole = require('../../../Apps/Jasmine/jasmine-standalone-2.0.0/lib/jasmine-2.0.0/console.js') // WHAT THE? I DON'T EVEN KNOW WHAT THIS MEANS jasmine = jasmine.core(jasmine); jasmineConsole.console(jasmineConsole, jasmine) // Set up the console logger jasmine.getEnv().addReporter(new jasmine.ConsoleReporter({ print: console.log })); // Create some global functions to avoid putting jasmine.getEnv() everywhere describe = jasmine.getEnv().describe; it = jasmine.getEnv().it; […]

如何从Node项目的命令行运行Jasminetesting框架2.0

以前,我使用了npm包节点jasmine-node 。 但是,文档说它只支持Jasmine 1.3.1。 我想在Node项目上运行Jasmine 2.0testing。 我发现茉莉花的核心 ,它看起来像它包含茉莉花2.0库,但不是命令行亚军。 我需要做些什么才能做到这一点?

用Jasmine / NodetestingAngular:未捕获types错误“不能设置'mock'的属性undefined

我正在尝试创build“Angular.js in Action”中描述的Jasmineunit testing。 该应用程序运行正常,但我试图运行我的testing时,不断收到此错误在node.js命令提示符。 我的configuration: module.exports = function(config) { config.set({ // base path, that will be used to resolve files and exclude basePath: '', // frameworks to use frameworks: ['jasmine'], // list of files / patterns to load in the browser files: [ 'javascripts/angular.min.js', 'javascripts/angular-mocks.js', 'javascripts/app.js', 'tests/angelloModelSpec.js', ], 我的index.html标题: <head> <script src="javascripts/angular.min.js" type="text/javascript"></script> <script […]

为什么茉莉花节点不拿起我的帮手脚本?

这个问题很可能是因为我缺乏以前使用node.js的经验,但是我希望jasmine-node只是让我从命令行运行我的jasmine规范。 TestHelper.js: var helper_func = function() { console.log("IN HELPER FUNC"); }; my_test.spec.js: describe ('Example Test', function() { it ('should use the helper function', function() { helper_func(); expect(true).toBe(true); }); }); 这些是目录中唯一的两个文件。 那么,当我这样做: jasmine-node . 我明白了 ReferenceError: helper_func is not defined 我敢肯定这个答案很简单,但是我没有find任何超级简单的介绍,或者在github上的任何明显的例子。 任何意见或帮助将不胜感激! 谢谢!

如何强制jasmine-nodetesting中的错误分支

我正在用jasmine-nodetesting节点服务器中API端点后面的控制器逻辑。 以下是这个控制器逻辑通常的样子: var getSummary = function(req, res) { var playerId = req.params.playerId; db.players.getAccountSummary(playerId, function(err, summary) { if (err) { logger.warn('Error while retrieving summary for player %d.', playerId, err); return res.status(500).json({ message: err.message || 'Error while retrieving summary.', success: false }); } else { res.json({success: true, summary: summary}); } }); }; 以下是我如何成功testingelse块: describe('GET /api/players/:playerId/summary', function() { […]

你如何在浏览器中运行Jasminetesting?

我正在使用茉莉-npm 。 jasmine-init将它设置为可以在terminal中运行jasmine来testing你的代码。 我记得之前在浏览器中看到这些testing,并希望在那里看到它们。 我将如何在浏览器中运行testing? (这看起来应该是很容易研究的东西,但是我发誓,我已经花了2个多小时研究这个问题了,而且不能算出来)。

在Webstorm 11中用jasmine运行/debuggingnode.jstesting用例

我安装Webstorm 11,并想运行我的testing(对于node.js应用程序)与茉莉花实施。 然而这并不容易。 我只能input命令行'jasmine'命令,testing将运行,但在这种情况下,我无法debugging代码。 那么有没有办法configurationWebstorm处理茉莉花规格?

unit testing使用服务方法的节点js控制器的最佳方法是什么?

我的控制器=>下面的控制器是使用reqpoertService.getFiles方法,该方法本身使用外部的API来调用数据。 function getFiles(req, res) { reportService.getFiles({ fromDate: req.query.fromdate, endDate: req.query.enddate, fileTypes: req.query.filetypes || [], fileStatus: req.query.filestatus || [] }) .then(data => { logger.info('-> reportService.getFiles :: Successfully fetched data', resolveLogger({ statusCode: res.statusCode }) ); res.send(data); }) .catch(err => { logger.error('<- OOPS :: reportService.getFiles fail to fetch data'); res.status(statusCodes.INTERNAL_SERVER_ERROR).send({}); logger.error('<- ERROR', resolveLogger({ statusCode: res.statusCode, errMessage: err.message, errorStack: […]

茉莉花(摩卡)嵌套“它”testing

我试图testing随后的创build/删除项目(在mongoDB通过mongoose)。 创build是asynchronous的问题,它返回创build的项目在callback函数中的ID,我需要这个ID删除创build的项目,所以我尝试了摩卡(以不同的方式)下面的代码,但它没有工作。 describe('Item Model', function(){ it('should be able to create item', function(done){ var item = new Item({name: {first: "Alex"}); item.save(function(err, data){ it('should be able to deleted created item', function(done){ Item.delete({_id: data.id}, function(err, data){ done(err); }); }); }) }); }); 这种testing可以在摩卡或茉莉花中实施吗?