module.exports = {
  init: function() {
    global.isTest = true;

    return (fn, dp, title) => {
      const request = require('supertest');
      var port;

      try {
        port = require('find-port-sync')();
      }
      catch (_) {
        port = 62369;
      }

      global.DP_TEST_PORT = port;

      describe(title || 'WebServer', () => {
        var app = undefined;

        before(() => {
          app = dp.listen(port);

          if (global.__dpModelEngine__.destroyed) {
            global.__dpModelEngine__.registerDsn(dp.config.cfg.databaseDsn);
            global.__dpModelEngine__.destroyed = false;
          }
        });

        after(() => {
          if (global.__dpModelEngine__ && global.__dpModelEngine__._conn) {
            Object.keys(global.__dpModelEngine__._conn).forEach((key) => {
              global.__dpModelEngine__._conn[key].destroy();
              delete global.__dpModelEngine__._conn[key];
            });
          }

          if (global.__dpSessionEngine__ && global.__dpSessionEngine__.engine) {
            global.__dpSessionEngine__.engine().close();
          }

          global.__dpModelEngine__.destroyed = true;

          app.close();
          app = undefined;
        });

        fn(() => {
          return request(app);
        });
      });
    }
  }
};

@@ -76,17 +76,18 @@
 rn (fn, 
-d
+ap
 p, title
@@ -359,18 +359,19 @@
     var 
-ap
+htt
 p = unde
@@ -411,22 +411,27 @@
         
-ap
+htt
 p = 
+app.
 dp.liste
@@ -541,16 +541,20 @@
 sterDsn(
+app.
 dp.confi
@@ -1190,18 +1190,19 @@
         
-ap
+htt
 p.close(
@@ -1214,18 +1214,19 @@
         
-ap
+htt
 p = unde
@@ -1289,18 +1289,19 @@
 request(
-ap
+htt
 p);%0A    

fix reference error.