Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help: Multiple callbacks error with mongo AND lab.before #728

Closed
icetbr opened this issue Jul 25, 2017 · 3 comments
Assignees
Labels
bug
Milestone

Comments

@icetbr
Copy link

@icetbr icetbr commented Jul 25, 2017

Hi, I'm getting the "Multiple callbacks or thrown errors received" error when connecting to my DB on the before method. I get expected error when everything is on the same place (either in lab.test or lab.before). Any ideas?

Multiple callbacks or thrown errors received in test "Before each sumTotal" (error): Expected 1 to equal specified value
      at lab.experiment.lab.test.drop (/home/user/projects/myProject/t1/c.js:41:26)
      at db.collections (/home/user/projects/myProject/t1/c.js:26:16)
      at _combinedTickCallback (internal/process/next_tick.js:67:7)
      at process._tickDomainCallback (internal/process/next_tick.js:122:9)
'use strict';
var Lab = require('lab');
var lab = exports.lab = Lab.script();
var Code = require('code');
var expect = Code.expect;

var MongoClient = require('mongodb').MongoClient;

let db;

const connect = function (cb) {
    MongoClient.connect(myUri, (err, db1) => {
        db = db1;
        cb();
    });
};

const drop = function (cb) {
    db.collections((err, collections) => {
        cb();
    });
};

lab.experiment('sumTotal', function () {

    lab.beforeEach((done) => {
        connect(() => {
            done();
        });
    });

    lab.test('default', function (done) {
        drop(() => {
            expect(1).to.equal(2);
            done();
        });
    });

});
@geek

This comment has been minimized.

Copy link
Member

@geek geek commented Jul 25, 2017

The error looks correct, that expect(1).to.equal(2); fails: 'Expected 1 to equal specified value'

What are you expecting to see?

@icetbr

This comment has been minimized.

Copy link
Author

@icetbr icetbr commented Jul 25, 2017

Failed tests:

  1) sumTotal default:

      actual expected

      12

      Expected 1 to equal specified value

      at /home/user/projects/myProject/t1/c.js:41:26

No 'multiple'. That makes it hard to read large error messages and it usually only shows up after 2000ms (timeout)

@geek

This comment has been minimized.

Copy link
Member

@geek geek commented Jul 25, 2017

@icetbr understood, I'll mark this as a bug. We should definitely make that error message clearer.

@geek geek added the bug label Jul 25, 2017
@geek geek self-assigned this Aug 11, 2017
@geek geek added this to the 14.1.2 milestone Aug 11, 2017
@geek geek closed this in #732 Aug 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.