0

Here's my test

'use strict';

var assert = require('assert');
var sinon = require('sinon');
var proxyquire = require('proxyquire');
var Lab = require('lab');

var lab = exports.lab = Lab.script();

lab.experiment("src.mysql", function () {

    var server = {
        settings: {
            app: {
                mysql: {
                    connectionLimit: 10,
                    host: "none",
                    user: "me",
                    password: "nope",
                    database: "db"

                }
            }
        },
        expose: sinon.stub()
    };
    var mysql = sinon.stub();
    var next = sinon.stub();
    var plugin = proxyquire('../../src/mysql', {
        mysql: mysql
    });

    lab.test("successful loads", function(done) {
        plugin.register(server, {}, next, function(err) {
            assert(err === 'hello');
        });

        done();
    });
});

I'm not getting an error, but the test is passing, which is a false positive. Not sure what I am doing wrong

Gergo Erdosi
  • 40,904
  • 21
  • 118
  • 94
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189

1 Answers1

2

The latest version of hapi 8.x.x uses a new method for loading plugins, you should call server.register with arguments described here http://hapijs.com/api#serverregisterplugins-options-callback.

Matt Harrison
  • 13,381
  • 6
  • 48
  • 66
simon-p-r
  • 3,623
  • 2
  • 20
  • 35