javascript - sails.js relifting with mocha -


i have mocha tests need re-lift sails different configuration mocks policies using moduleloaderoverride. in general, working, seems sails not lowering , re-lifting properly.

the utility file management of sails instance tests:

// util  var sails = require('sails/lib/app'),     sails;  module.exports = {   sailsinstance: undefined,   testconfigs: {},     start: function(callback) {     this.sailsinstance = new sails();     /*       config not enforced remaining tests,       quick lift our code can use sails config       parser , extract other configs easily.      */     this.sailsinstance.lift({}, function(err, server) {       sails = server;       // populate this.testconfigs object here       this.configuresails('defaultconfig', callback);     }.bind(this));   },    end: function(callback) {     this.sailsinstance.lower(callback);   },     configuresails: function(configname, callback) {     console.log('lifting with:', configname);      var launchconfig = this.testconfigs[configname];      console.log('lowering');     this.sailsinstance.lower(function (err) {       console.log('lowered');        this.sailsinstance = new sails();        console.log('lifting');       this.sailsinstance.lift( launchconfig, function(err, server) {         console.log('lifted');         global.sails = server;          return callback(err);       }.bind(this));     }.bind(this));   }, 

in test-bootstrap file:

// test-bootstrap before(function (done){      util.start(done); });  after(function(done) {   testutils.end(done); }); 

in user test file:

// user test describe('user permissions', function() {   before(function(done){     util.configuresails('enablepolicies', done);   }); }); 

so, goes in bootstrap, fails when it's lifted second time in user test file. exact log i'm getting this:

lifting with: defaultconfig lowering lowered lifting lifted    user permissions lifting with: enablepolicies lowering     1) "before all" hook    0 passing (3s)   1 failing    1) user permissions "before all" hook:      uncaught error: trying start server on port 1337 can't...something else running on port! please disable other server, or choose different port , try again.     lowered lifting // npm error spam 

i've seen error when sails tries lift twice in row, shouldn't happening since i'm lowering first. suspect scope issue since start function 2 lifts without running on port, user test fails. difference see there configuresails function being called user test file instead of util file, i'm not sure if that's problem or how solve if problem.

any thoughts? in advance


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -