javascript - How to setup namespaces in Jasmine for testing? -


i need add functionality javascript class want test using jasmine. class definition goes this:

game.player.customplayersetup = function() {   ... }; 

if remove game.player can write normal tests , have them pass. when try leave game.player in class definition customplayersetup, reference error game not defined. how define test?

to answer charles' suggestion, if declare game , player vars in jasmine test file before the require line still gives me, in

game = {}; game.player = {};  customplayersetup = require("../customplayersetup").customplayersetup;  describe("custom player setup", function() {   ... }); 

the same error points production code file, , not test file. i'm using jasmine-node run tests.

most in spec-runner have whatever file instantiates game and/or player below file running spec (or didn't include @ all).

if that's not case try posting spec-runner 1 of tests fails.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -