2016-07-25 2 views
0

Я использую sails-sequelize-hook в своем приложении sails. Я следую документации this, чтобы написать мой первый тест модуля контроллера для моего приложения. Мой bootstrap.test.js выглядит так.Парусное испытание с парусами-крючком-секвестром

var sails = require('sails'); 

before(function(done) { 

    // Increase the Mocha timeout so that Sails has enough time to lift. 
    this.timeout(5000); 

    sails.lift({ 
    }, function(err, server) { 
     if (err) return done(err); 
     // here you can load fixtures, etc. 
     done(err, sails); 
    }); 
}); 

after(function(done) { 
    // here you can clear fixtures, etc. 
    sails.lower(done); 
}); 

Мои соединения заключается в следующем

module.exports.connections = { 

    dbTest: { 
     user: 'root', 
     password: 'root', 
     database: 'myappdb', 
     options: { 
      host: 'localhost', 
      dialect: 'mysql', 
      pool: { 
       max: 5, 
       min: 0, 
       idle: 10000 
      } 
     } 
    }, 
} 

Когда я бегу npm test я получаю следующее сообщение об ошибке

error: In model (myfirstmodel), invalid connection :: { user: 'root', 
    password: 'root', 
    database: 'myappdb', 
    options: 
    { host: 'localhost', 
    dialect: 'mysql', 
    pool: { max: 5, min: 0, idle: 10000 }, 
    logging: [Function: _writeLogToConsole] } } 
error: Must contain an `adapter` key referencing the adapter to use. 
npm ERR! Test failed. See above for more details. 

Что я здесь отсутствует? Какое имя адаптера я даю? Кажется, я потерян.

+0

У меня та же проблема, вы нашли способ обойти это? Прыгая парусами, я ненавижу, что это проклятые кишки. – yBrodsky

+0

Да, да. Пожалуйста, обратитесь к моему ответу ниже и дайте мне знать, если он решает вашу проблему. –

+0

Да, найдено то же решение. Благодаря ;) – yBrodsky

ответ

0

Подставляя это в моей bootstrap.test.js решить мою проблему

var sails = require('sails'); 

before(function(done) { 

    // Increase the Mocha timeout so that Sails has enough time to lift. 
    this.timeout(10000); 

    var rc; 
    try { 
     rc = require('rc'); 
    } catch (e0) { 
     try { 
      rc = require('sails/node_modules/rc'); 
     } catch (e1) { 
      console.error('Could not find dependency: `rc`.'); 
      console.error('Your `.sailsrc` file(s) will be ignored.'); 
      console.error('To resolve this, run:'); 
      console.error('npm install rc --save'); 
      rc = function() { return {}; }; 
     } 
    } 

    // Start server 
    sails.lift(rc('sails') 
     , function(err, server) { 
     if (err) return done(err); 
     // here you can load fixtures, etc. 
     done(err, sails); 
    }); 

}); 

after(function(done) { 
    // here you can clear fixtures, etc. 
    sails.lower(done); 
}); 
Смежные вопросы