Any ideas on how to run Mocha tests for Mean.js?

Oct 31, 2014 at 4:01 PM
The issue is the following: while I made them discoverable (finally), they are still unusable. Because:
Test Name:  User Model Unit Tests: Method Save should be able to save without problems
Test Outcome:   Failed
Result StandardError:   
C:\SomeProject\node_modules\mongoose\lib\index.js:323
      throw new mongoose.Error.MissingSchemaError(name);
            ^
MissingSchemaError: Schema hasn't been registered for model "User".
Use mongoose.model(name, schema)
    at Mongoose.model (C:\SomeProject\node_modules\mongoose\lib\index.js:323:13)
    at Object.<anonymous> (C:\SomeProject\app\tests\user.server.model.test.js:8:21)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at C:\SomeProject\node_modules\mocha\lib\mocha.js:184:27
    at Array.forEach (native)
I know that similar probjem once happened to Grunt testing, so I tried the same solution - add a server.js dependency to mocha.js. Well, that did not work.
This method is called in both find_tests and run_tests:
function preloadApp(projectFolder) {
    try {
        var app = require(projectFolder + '\\server.js');
        return app;
    } catch (ex) {
        return null;
    }
}
well, it turned out this way:
Test Name:  User Model Unit Tests: Method Save should be able to save without problems
Test Outcome:   Failed
Result StandardError:   
 NODE_ENV is not defined! Using default development environment
C:\SomeProject\node_modules\mongoose\lib\index.js:323
      throw new mongoose.Error.MissingSchemaError(name);
            ^
MissingSchemaError: Schema hasn't been registered for model "User".
Use mongoose.model(name, schema)
    at Mongoose.model (C:\SomeProject\node_modules\mongoose\lib\index.js:323:13)
    at Object.<anonymous> (C:\SomeProject\app\tests\user.server.model.test.js:8:21)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at C:\SomeProject\node_modules\mocha\lib\mocha.js:184:27
    at Array.forEach (native)
My next step is to straight away implement server,js analogue in mocha.js and see what can be done.
If it does not help, I plan on to try and run grunt from it.

But maybe I am moving in a wrong direction and all this have already been solved?
Anyone? Someone?