Open MartinKnopf opened 10 years ago
To clarify, are you imagining the interfake instance being completely set up as part of your gruntfile and then used as part of the test environment? Or rather, providing the interfake methods as part of the test environment?
Hi,
your first idea is what I mean. I'm using grunt-contrib-connect to serve frontends on my local machine. I would like a connect middleware to fake REST APIs but I don't want to configure interfake inside the Gruntfile (since this tends to get big).
Let me add to my previous code sample:
myInterfakeInstance.js
var Interfake = require('Interfake')
, interfake = new Interfake();
interfake.createRoute({...});
module.exports = interfake;
Gruntfile.js
connect: {
options: {
port: 8080,
hostname: 'localhost'
},
test: {
options: {
middleware: function (connect) {
return [
require('./myInterfakeInstance').asMiddleware()
];
}
}
}
},
Ah, I see. Okay, I'll look into this at some point if someone doesn't get here first - I imagine it's not too hard to do. I suppose there are some hooks so that we can start and then stop the server at the appropriate moments?
Cool!
The connect server can be started with Grunt:
grunt.registerTask('devserver', ['connect:server:keepalive']);
It would be nice to use interfake in a Grunt setup as a connect middleware like this: