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
Hi guys, I'm trying to test two routes that are pretty much the same except that one of them is more specific as the latest url segment is a hardcoded value (edit) while the other has a parameter (:slug).
The issue I'm experiencing is that when the request is executed it will call both routes (edit, show) causing my mock never() expectation never pass :(
Am I doing something wrong? I dont't get why both routes are executing if one of them is more specific...
This is the test:
varrequest=require('supertest'),express=require('express')describe('routes',function(){it('should call only edit',function(done){varusersController=require('./users-controller');varsandbox=require('sinon').sandbox.create();varmockController=sandbox.mock(usersController);mockController.expects('edit').yields(null).once();mockController.expects('show').never();varapp=express();app.get('/users/:id/edit',usersController.edit);app.get('/users/:id/:slug',usersController.show);request(app).get('/users/123/edit').end(function(err,res){if(err)throwerr;mockController.verify();done();});});});
and here is the users-controlle.js I'm mocking above:
Hi guys, I'm trying to test two routes that are pretty much the same except that one of them is more specific as the latest url segment is a hardcoded value (edit) while the other has a parameter (:slug).
The issue I'm experiencing is that when the request is executed it will call both routes (edit, show) causing my mock never() expectation never pass :(
Am I doing something wrong? I dont't get why both routes are executing if one of them is more specific...
This is the test:
and here is the users-controlle.js I'm mocking above:
The text was updated successfully, but these errors were encountered: