Tag: jasmine node

如何在浏览器中运行茉莉花节点testing(例如使用testem)?

如何在浏览器中使用testem( https://github.com/testem/testem )运行jasmine-node( https://github.com/mhevery/jasmine-node )testing? 他们都在nodeJS上运行,但我不知道如何将它们结合起来。 我想知道是否有任何我可以使用的库,或者是否有人成功定制了两个库来在浏览器中loggingtesting输出。

练习练习:茉莉节点。 – 找不到命令

我正在尝试运动练习的第一个练习。 我按照自述说明安装了Homebrew,然后安装了CLI。 一切都很好。 然后我input命令行下载第一个testing – Hello World。 再次,这工作得很好。 下一条指令是 Execute the tests with: jasmine-node . 我假设这是要input到terminal? 这是我试过的,它说“找不到命令”。 没有其他的指示。 我从来没有遇到过茉莉花。 我通过npm分别下载了jasmine-node, npm install jasmine-node -g …但这仍然没有区别。 任何人都可以build议我去哪里错了? 谢谢。

茉莉花节点期望不执行

今天我开始testing茉莉花,这对我来说是新的。 由于我正在使用一个使用NodeJS开发的GraphQL服务器,因此我正在使用jasmine-node 。 以下是我自己写的第一个规范,我认为它是工作的: const request = require('request'); const config = require('../sources/config'); const base_url = `http://localhost:${config.graphqlPort}/${config.graphqlRoute}`; describe("GraphQLServer.", () => { it("Should expect something.", () => { expect(1).not.toEqual(2); expect(1).toEqual(1); expect(true).toBe(true); expect(false).not.toBe(true); }); describe('When request is made.', () => { it('Returns statuscode 200.', () => { request.get(base_url, (error, response, body) => { console.log('Error: ', error); console.log(base_url); console.log('StatusCode: […]

未能在茉莉花节点中显示的testing

我有一个Web服务的基本testing: var request = require('http'), url = 'http://localhost:1337/'; describe('webservice', function() { it('should respond to /ping', function(done) { request.get(url + 'ping', function(res) { expect(res.statusCode).toBe(200); res.on('data', function(body) { var json = JSON.parse(body); expect(json.message).toBe("Hi, I'm alive"); expect(json.date).toBeDefined(); done(); }); }); }); }); 这似乎工作正常: $ jasmine-node –verbose tests/ping/ webservice should respond to /ping Finished in 0.032 seconds 1 test, […]

用jasmine监听asynchronous函数

我正在使用茉莉花节点来testing我的服务器。 我想伪造/绕过我的用户类中的一些validation相关的代码。 所以我会设置一个这样的间谍 – var user = { email: 'email@email.com', password: 'password' } spyOn(User, 'validateFields').andReturn(user); 但是validateFields函数是asynchronous的… User.prototype.validateFields = function(user, callback) { // validate the user fields callback(err, validatedUser); } 所以我实际上会需要这样的一个callback而不是回报 – var user = { email: 'email@email.com', password: 'password' } spyOn(User, 'validateFields').andCallback(null, user); 茉莉花是可以做到的吗?

具有请求的茉莉花节点 – testingredirect不遵循redirect的终结点

即使添加followAllRedirects只会将response.statusCode从302更改为200但是body仍然是前一个响应的内容,而响应的所有其他属性都反映了旧的response 。 注意:我正在使用grunt进行testing。 没有遵循redirect的原因?

特拉维斯CI超时节点茉莉花testing,但通过本地

我一直在一个命令行应用程序的节点,做一些文件系统读取和表示应用程序的东西,所有我的testing本地通过,但是特拉维斯似乎有一个问题时,build设(超时,这是一个茉莉花节点事情)。 这是我得到的 .travis.yml language: node_js node_js: – '>=0.10' before_script: – npm install -g grunt-cli – npm link script: – "grunt –verbose" sickmerge_spec.js // Set the test environment process.env.NODE_ENV = 'test'; // Dependencies var exec = require('child_process').exec, fs = require('fs'), version = require('../package.json').version, request = require('request'); // Helper function to exectue the sickmerge cli function execSickmerge […]

如何停止stream更改我的原始缓冲

我正在使用stream-to-promise npm模块在我的茉莉花testing中创buildmultipart / form-data载荷。 我的有效载荷包括一个图像文件作为缓冲区,但是当有效载荷通过stream承诺,它改变或破坏我的原始图像缓冲区在有效载荷莫名其妙,所以我的testing失败。 有没有办法来防止这一点? it('test /identity-verification/your-first-form-of-id POST with validation passing', function(done){ var form = new FormData(); var image = fs.createReadStream("image.png"); streamToBuffer(image, function (err, buffer) { form.append('firstID', 'passport'); form.append('firstIDImage', buffer); var headers = form.getHeaders(); streamToPromise(form).then(function(payload) { var options = { method: 'POST', url: '/identity-verification/your-first-form-of-id', payload: payload, headers: headers }; server.inject(options, function(response) { expect(response.statusCode).toBe(302); expect(response.headers.location).toMatch('/identity-verification/your-first-form-of-id/upload-successful'); […]

茉莉花节点testing执行两次

我的茉莉花节点testing执行两次。 我从Grunt任务和Jasmine命令运行这些testing。 结果是一样的我的testing运行两次。 我的package.json: { "name": "test", "version": "0.0.0", "dependencies": { "express": "4.x", "mongodb": "~2.0" }, "devDependencies": { "grunt": "~0.4.5", "grunt-jasmine-node":"~0.3.1 " } } 这是我的Gruntfile.js摘录: grunt.initConfig({ jasmine_node: { options: { forceExit: true, match: '.', matchall: true, extensions: 'js', specNameMatcher: 'spec' }, all: ['test/'] } }); grunt.loadNpmTasks('grunt-jasmine-node'); grunt.registerTask('jasmine', 'jasmine_node'); 我的一个testing文件: describe("Configuration setup", function() { it("should load […]

茉莉花节点找不到spec模块

我有一个用coffeescript编写的准系统规范: # test/foobar.spec.coffee describe "falsy test", -> it "should fail", -> expect(true).toBe false 当我从项目目录运行jasmine-node –coffee test/foobar.spec.coffee ,出现以下错误: Exception loading: /Users/myuser/programming/project/test/foobar.spec.coffee { [Error: Cannot find module '/Users/myuser/programming/project/test/foobar.spec'] code: 'MODULE_NOT_FOUND' } 我在用: node –version v0.10.8 jasmine-node –version 1.13.0 有谁知道这是为什么发生?