Monday, 22 May 2017

Mocha tests do not run in sails 1.0

I have mocha tests that has code like this

request(sails.hooks.http.app) 
    .post('<my endpoint>') 
    .type('application/json') 
    .auth(username, pass) 
    .send(data) 
    .expect(200) 
    .end(function (err) { if (err) { return done(err); }}

which used to work fine before upgrading to sails 1.0.

Now it throws a 404 for this test and for every other test like this. The request enters neither the middleware nor the policy nor the controller. Which means it is failing at a core hook level. Any idea how to fix this? request is require('supertest'). The URL works exactly the same when tested with Postman REST client.



via Pratik Mandrekar

No comments:

Post a Comment