Expresso project - mocha tests problem

Hey folks,

I am working on the Expresso project Expresso project in the web development path and I am having problems with the test run to check the code.

I experience two problems:

  • When I run the tests by typing “npm test” only a part of them is shown, like 1/3 of them.

  • The console hangs and doesn’t return back to the user.

Can you help me understand why this is happening?

Here I have pasted the main project files I am working on.

NOTE: I have tried to include the test.js file, but it’s too long.

server.js

const express = require('express');
const app = express();
const PORT = process.env.PORT || 4000;

const errorHandler = require('errorhandler');

const apiRouter = require('./api/api');

app.use('/api', apiRouter);

app.use(errorHandler());

app.listen(PORT, () => {
    console.log(`Listening on port ${PORT}`);
});

module.exports = app;

api.js

const express = require('express');
const apiRouter = express.Router();
const employeesRouter = require('./employees');

    // <<< api/employees >>>
apiRouter.use('/employees', employeesRouter);

module.exports = apiRouter;

employees.js

const express = require('express');
const employeesRouter = express.Router();

const sqlite = require('sqlite3');
const db = new sqlite.Database('./database.sqlite');

    // <<< api/employees >>>
employeesRouter.get('/', (req, res, next) => {
    const sql = 'SELECT * FROM Employee WHERE is_current_employee = 1';

    db.all(sql, (error, employees) => {
        if (error) {
            next(error);
        } else {
            res.status(200).json({ employees: employees });
        }
    });

});

module.exports = employeesRouter;