"namespace is undefined" problem when using jsTestDriver, Idea 9 and testing 3 test cases. Sometimes it just outright hangs
I just started using jsTestDriver and I really like it, but all of a sudden, I just started getting a very weird error and I'm not sure what the heck I did to create it. Actually, if I try and run a basic Greeter test, the same problem happens.
Here's an example of one of my javascript files/classes under test:
myapp = myapp || {};
myapp.Module = function() {
...
};
All of the classes follow this pattern.
My test classes generally look like this (I'll give a really simple one):
ModuleTest = Test开发者_JAVA百科Case("ModuleTest");
ModuleTest.prototype.testInit = function() {
var module = new myapp.Module(); // <---- it bombs here, on every test!
assertFalse(module.isStarted);
module.init();
assertTrue(module.isStarted);
};
It bombs when it gets to "new myapp.Module()". Here is the error message that is given about 30 times for all my tests:
myapp is not defined
/src/test/webapp/js/ModuleTest.js:4
Here is my configuration file:
server: http://localhost:9876
load:
- src/main/webapp/js/jquery/*.js
- src/main/webapp/js/*.js
- src/test/webapp/js/*.js
Does anyone have any idea what the heck is wrong? Sometimes when I run all the tests in IDEA, my IDE just hangs altogether or takes like many minutes for jsTestDriver to finally report the above results...
:(
I faced the same issue after I moved to v.1.3.1. In my case the problem was with file encoding. I use Visual Studio for the development, it adds byte order mark (3 extra bytes) in the beginning of the file. It's possible to see these bytes in Far manager. If you use VS try to save the file as the following: "File->Advanced save options->" Encoding: Unicode (UTF-8 without signature) - Codepage 65001. It should fix your problem.
精彩评论