0

In my Sails application I have some integration tests in Mocha/Chai/Supertest that run against sails-disk database until today. Today I tried switching to actual databases, to test performance and behaviour as well as reliability of my models. Installed Mongo, run tests, everything went ok.

However after I installed the sails adapters for MySql and PgSql and both database suites locally I had problems running tests against both databases. As I find the behaviors similar I chose to detail them in the same thread.

PgSql: Half of the test pass, those that don't pass don't throw any specific error at first. However when I debug them I find they throw 'socket hang up' errors.

MySql: Here, if I run the tests all of them fail and if I debug them step by step they pass. Note that none of the tests have weird async behaviour which would have explained why they could pass while debugging (the app would have time between breakpoints to execute 'expected' stuff), they are quite plain and simple.

Haven't found a solution or an explanation to this so far. I am developing on a Windwos 7 X64 OS.

Update: On further inspection it seems some of the tests failed due to timeout errors (that for some reason weren't being shown as timeout errors). After setting the mocha timeouts a little higher, more of the tests now pass, which is a little weird as on mongo any test suite took less than a second to run. Regarding those tests that still fail on this extended timeout setup it looks like during debug the controller is never reached. I'm using supertest for firing requests, something which after some modifications now looks like this:

var testReq = request(sailsAppEndpoint)
      .get(specificLink)
      .set('Authorization', token)
      .expect(200);
testReq.end(function (err, res) {
        expect(err).to.be.null;
});

For some reason, inside the .end function the callback is never called. Still looking into this.

Vee6
  • 1,527
  • 3
  • 21
  • 40
  • This is **way** too vague for anyone to begin to help you. – Travis Webb Mar 08 '15 at 20:20
  • True, however it is all I have. I also did run the tests in a Ubuntu environment and the problems where more or less the same. I will try building a single purposed application and run some tests with it. – Vee6 Mar 10 '15 at 11:57

0 Answers0