You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently having a test database is supported by Travis. If we use that along with sails.request(), we'll be able to fully test requests to the server rather than just testing service methods, which should make our unit tests much more effective.
I couldn't find any good documentation on the sails.request() function (it was briefly mentioned in this migration guide), but I messed around and came up with an example unit test.
describe('API calls',function(){this.timeout(10000);before(functionbeforeRunningAnyTests(done){// Load the app (no need to lift to a port)require('sails').load({log: {level: 'warn'},hooks: {grunt: false}},functionwhenAppIsReady(err){returndone(err);});});it('Gets a user profile correctly',function(done){sails.request({method: 'get',url: '/user/get/not_an_aardvark'},function(err,clientRes,body){assert.equal(clientRes.statusCode,200);assert.equal(body.name,'not_an_aardvark');assert.ok(body.isMod);assert.notOk(body.redToken);// don't send a user's redToken to the client// etcdone(err);});});});
The text was updated successfully, but these errors were encountered:
Apparently having a test database is supported by Travis. If we use that along with
sails.request()
, we'll be able to fully test requests to the server rather than just testing service methods, which should make our unit tests much more effective.I couldn't find any good documentation on the
sails.request()
function (it was briefly mentioned in this migration guide), but I messed around and came up with an example unit test.The text was updated successfully, but these errors were encountered: