New to node and making a generic express application that connects to MySQL db using sequelize. Doing some unit tests on the db connection with jasmine-node and I keep getting timeouts when i try to connect with sequelize.
// Test the MySQL connection
describe("MySQL", function() {
it("is connectable", function(next) {
var mysql = require('mysql');
var dbconfig = require('../config/database');
var connection = mysql.createConnection(dbconfig.connection);
connection.connect(
function(err, db) {
expect(err).toBe(null);
connection.end();
next();
}
);
});
it("is connectable using sequelize", function(next){
var dbconfig = require('../config/database');
var Sequelize = require('sequelize');
var sequelize = new Sequelize(dbconfig.connection.database, dbconfig.connection.user, null,
function(err, db){
expect(err).toBe(null);
sequelize.close();
next();
}
);
});
});
Of the two tests above, the first passes fine, but the test for sequelize times out. Here is the what I get on the console.
Failures:
1) MySQL is connectable using sequelize
Message:
timeout: timed out after 5000 msec waiting for spec to complete
Stacktrace:
undefined
Finished in 6.267 seconds
Here is the database config file.
// config/database.js
module.exports = {
'connection': {
'dialect': 'mysql',
'user': 'root',
'password': '',
'host': 'localhost',
'port' : '3306',
'database': 'my_node_db'
}
};