diff --git a/.gitignore b/.gitignore
index 979717eb93b624b88c6749fccd981b0ccb7b2e8d..136ccb71c2aa2bcefad07404cf99bfc61ab4d9f7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,4 @@ build/*
 
 config.json
 docs/
+test_config.json
diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index 1f23dd9ee0b5c083c7f66d6d6650982a34a748a6..3a61dacebd8b3fbb5228f258a536f734c974a840 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -48,6 +48,8 @@ gulp.task('compile', () => {
     // copy configuration file to build directory
     gulp.src('config.json')
         .pipe(gulp.dest('build'));
+    gulp.src('test_config.json')
+        .pipe(gulp.dest('build'));
 });
 
 gulp.task('build', ['compile']);
diff --git a/src/libs/app.js b/src/libs/app.js
index 4e3e51c6bf3d216a519ce5a33e16b45941c75040..bed5deb7a92ad53a74173b9a4e9f2addb16d9e55 100644
--- a/src/libs/app.js
+++ b/src/libs/app.js
@@ -10,6 +10,7 @@ const libs = `${process.cwd()}/libs`;
 
 const log = require(`${libs}/log`)(module);
 
+process.env.NODE_ENV = process.env.NODE_ENV || 'development';
 const config = require(`${libs}/config`);
 const cache = require('apicache').options({ debug: config.get('debug') }).middleware;
 
@@ -22,7 +23,6 @@ const mongoose = require(`${libs}/db/mongoose`);
 const db = mongoose();
 
 // Set default node environment
-process.env.NODE_ENV = process.env.NODE_ENV || 'development';
 
 // Parse json received in requests
 app.use(bodyParser.json());
diff --git a/src/libs/config.js b/src/libs/config.js
index 5aea5a9ca50efd0dac2253dd23690229431236dc..dd2d88c48ccbd82fc1524b361ceee6321c985054 100644
--- a/src/libs/config.js
+++ b/src/libs/config.js
@@ -1,8 +1,24 @@
 const nconf = require('nconf');
 
+let config_file;
+
+switch(process.env.NODE_ENV) {
+    case 'development':
+        config_file = 'config.json';
+        break;
+    case 'test':
+        config_file = 'test_config.json';
+        break;
+    case 'production':
+        config_file = 'config.json';
+        break;
+}
+
 // Exports the config.json as an object with get functions
 nconf.argv()
     .env()
-    .file({ file: `${process.cwd()}/config.json` });
+    .file({ file: `${process.cwd()}/${config_file}` });
+
+console.log(nconf.get('mongodb'));
 
 module.exports = nconf;
diff --git a/src/test/test.js b/src/test/test.js
index 7501e5677bd288d13af16c60d26cfdf2af4a7a8d..90103f0ab21b0357c76bd1977bc7c00711343111 100644
--- a/src/test/test.js
+++ b/src/test/test.js
@@ -1,3 +1,5 @@
+process.env.NODE_ENV = 'test';
+
 const chai = require('chai');
 
 const dirtyChai = require('dirty-chai');