I have a problem with Sinon to work correctly for me. When I close the list on retro and test runs, app.get('/retro', retro.list) performs the original function retro.list instead of a stub. Since this happens, the test fails because the callCount stub is 0.
I am more familiar with coffeescript, and I also cut through things. Is there something that I donβt understand in the Javascript area, or how require('../routes/retro') works, or retro not the same in app.js and test.js
Thanks so much for the help and code below.
test.js:
var request = require('supertest') , retro = require('../routes/retro') , app = require('../app') , sinon = require('sinon'); require('should'); describe('GET /retro', function() {
app.js:
var express = require('express') , config = require('./config') , routes = require('./routes') , retro = require('./routes/retro'); var app = express(); config(app); app.get('/', routes.index); app.get('/retro', retro.list); module.exports = app;
retro.js:
var retro = { list: function(req, res){ console.log('actual called'); res.send("respond with a resource"); } } module.exports = retro;
source share