Unable to import a database connection from a file in Jest

Viewed 21

I have implemented jest in my project and tests are running fine until a database or Redis connection is needed

In my test file

// import  { databaseConnections }  from '../routes/api.js';

In my api.ts file

    export var databaseConnections : any = {};

async function initializeDB() {
    let result = await getDB();

    redisConnections = result['redisConnections'];
    databaseConnections = result['databaseConnections'];
}
initializeDB();


.....

When I am running the test this is the error I am getting

TypeError: Cannot read property 'Router' of undefined

  54 | var express_basic_auth_1 = require("express-basic-auth");
  55 | // Express router
 56 | exports.router = express_1["default"].Router();

What am i missing

0 Answers
Related