jasmine-node

How to run Jasmine tests on Node.js from command line

ε祈祈猫儿з 提交于 2019-11-28 20:03:55
How do I run Jasmine tests on Node.js from command line? I have installed jasmine-node via npm and written some tests. I want to run tests inside the spec directory and get results in the terminal, is this possible? EDIT It seems this is no longer the current best answer as the package is unmaintained. Please see the answer below You can do this from your test directory sudo npm install jasmine-node This installs jasmine into ../node_modules/jasmine-node then ../node_modules/jasmine-node/bin/jasmine-node --verbose --junitreport --noColor spec which from my demo does this Player - 5 ms should

Exporting classes with node.js

橙三吉。 提交于 2019-11-28 18:13:39
I have the following test code that is being ran by jasmine-node in a file called bob_test.spec.js require('./bob'); describe("Bob", function() { var bob = new Bob(); it("stating something", function() { var result = bob.hey('Tom-ay-to, tom-aaaah-to.'); expect(result).toEqual('Whatever'); }); }); In order to make the test pass, I've written the following production code in a file called bob.js "use strict"; var Bob = function() { } Bob.prototype.hey = function (text) { return "Whatever"; } module.exports = Bob; When I run the test - using jasmine-node . - I get the following F Failures: 1) Bob

How to run Jasmine tests on Node.js from command line

不想你离开。 提交于 2019-11-27 12:40:37
问题 How do I run Jasmine tests on Node.js from command line? I have installed jasmine-node via npm and written some tests. I want to run tests inside the spec directory and get results in the terminal, is this possible? 回答1: EDIT It seems this is no longer the current best answer as the package is unmaintained. Please see the answer below You can do this from your test directory sudo npm install jasmine-node This installs jasmine into ../node_modules/jasmine-node then ../node_modules/jasmine-node

Exporting classes with node.js

梦想与她 提交于 2019-11-27 11:07:53
问题 I have the following test code that is being ran by jasmine-node in a file called bob_test.spec.js require('./bob'); describe("Bob", function() { var bob = new Bob(); it("stating something", function() { var result = bob.hey('Tom-ay-to, tom-aaaah-to.'); expect(result).toEqual('Whatever'); }); }); In order to make the test pass, I've written the following production code in a file called bob.js "use strict"; var Bob = function() { } Bob.prototype.hey = function (text) { return "Whatever"; }

jasmine tests in karma: Uncaught ReferenceError: require is not defined

孤街浪徒 提交于 2019-11-27 00:58:46
Karma can not recognize 'require' statement in JSFileSpec.js file. Running karma.conf.js: (function() { describe("DummyEmitter creation", function(){ return it("creation", function(){ var DummyEmitter = require('Util.DummyEmitter'); var dummy = new DummyEmitter('someName'); return expect(dummy).toBeDefined(); }); }); })(); ReferenceError: require is not defined Sandeep Kumar I was facing same issue, when trying to use require('module_name') (CommonJS style modules) inside a test case and running it using Karma. The reason was require function is not available to browser (it is undefined ). To

jasmine tests in karma: Uncaught ReferenceError: require is not defined

孤人 提交于 2019-11-26 09:34:32
问题 Karma can not recognize \'require\' statement in JSFileSpec.js file. Running karma.conf.js: (function() { describe(\"DummyEmitter creation\", function(){ return it(\"creation\", function(){ var DummyEmitter = require(\'Util.DummyEmitter\'); var dummy = new DummyEmitter(\'someName\'); return expect(dummy).toBeDefined(); }); }); })(); ReferenceError: require is not defined 回答1: I was facing same issue, when trying to use require('module_name') (CommonJS style modules) inside a test case and