I'm trying to use the memory-connector as a datasource when doing integration testing. But it seems to always connect to the mongodb-datasource.
One major hack i have done is to change the datasource for each model to memory. But there must be a better way to do this. I'm running my tests from a gulp-task. My roflmao model-memory-hack:
var models = require('../server/model-config.json');
for (var key in models) {
var model = loopback.getModel(key);
loopback.configureModel(model, {dataSource: memory});
}
}
Is there any way to change the datasource for the app? Or do i have to change the datasource for each individual model..?
A way of doing this is to change the environment variable during testing, but so far, no luck.. I'm doing this with the gulp-task preprocess.
Hopefully by changing the environment variable, it would use datasources.integrationtesting.js, in which i have memory as a datasource.
My gulp-task:
return gulp.src('integration-tests/*.js')
.pipe($.preprocess({context: {NODE_ENV: 'integrationtesting'}}))
.pipe($.mocha())
I'm using:
- loopback-testing
- gulp-mocha
Appreciate any comments.. : )