I have a problem with my code. I am using Mocha+Chai+Mongodb. When I run de code this mesage show: "TypeError: Cannot read property 'collections' of undefined"
My code for test is this:
const chai = require('chai');
const calculadora = require('../../db');
const assert = chai.assert;
describe('TDD de Operações da Calculadora', () => {
it('Teste: Deve Somar 2 Números', () => {
assert.equal(calculadora.insert('Carol', 20, 'MG'),true);
});});
And my .js is this:
var ObjectId = require("mongodb").ObjectId;
var mongoClient = require("mongodb").MongoClient;
mongoClient.connect("mongodb://localhost:56467/locadora")
.then(conn => global.conn = conn.db("locadora"))
.catch(err => console.log(err))
function findAll(callback){
global.conn.collection('customers').find({}).toArray(callback);
}
module.exports = { findAll}
Someone could help me please? Thanks.