Mocha not exiting after test : <p>I'm starting with tests in Node. Using mocha, chai and nock (to intercept external HTTP api calls).</p>

<p>I have written 3 tests, all of them are a pass, however, when I added the 3rd test, mocha stopped exiting after running the tests, with no error or indication of anything wrong.</p>

<p>If I comment the 3rd test, mocha exits just fine.</p>

<p>This is the test causing the 'issue':</p>

<pre><code>describe('tokenizer.processFile(req, \'tokenize\')', () =&gt; {

    it('should tokenize a file', async () =&gt; {

        req = {
            file: {
                originalname: 'randomcards.txt',
                buffer: cardsFile_buffer
            },
            user: {
                displayName: user
            }
        };

        expect(Buffer.from(await tokenizer.processFile(req, 'tokenize'))).to.deep.equal(tokensFile_buffer);

    });

});
</code></pre>

<p>Again, that test is a pass, which baffles me.</p>

<p>Here's the code of tokenizer.processFile:</p>

<pre><code>processFile: function(req, whatTo){

        combinedLogger.info(`Request to ${whatTo} ${req.file.originalname} received. Made by: ${req.user.displayName}`);

        return new Promise(function(resolve, reject){

            const lines = [], responses = [];

            const lineReader = require('readline').createInterface({
                input: require('streamifier').createReadStream(req.file.buffer)
            });

            lineReader.on('line', line =&gt; {
                lines.push(line);
            });

            lineReader.on('close', async () =&gt; {

                //process every line sequentially

                try {

                    //ensure DB connected to mass insert
                    await db_instance.get_pool();

                    for(const line of lines) {
                        var response;
                        req.current_value = line;
                        if (whatTo == 'tokenize'){

                            response = await Tokenize(line);
                            db_instance.insertAction(req, 'tokenize', response);
                        }
                        else if (whatTo == 'detokenize'){
                            combinedLogger.info(`Request to detokenize ${line} received. Made by: ${req.user.displayName}`);
                            response = await Detokenize(line);
                            db_instance.insertAction(req, 'detokenize', line);
                        }
                        responses.push(response);
                    }

                    resolve(responses.join("\r\n"));

                }
                catch(error){
                    reject(error);
                }
            });

        });

    }
</code></pre>

<p>Functions Tokenize(value) and Detokenize(value) are also called in the other 2 tests, which when run, mocha exits just fine.</p>

<p>Any idea what's causing this?</p>

<p>Mocha version: 5.1.1</p>
