lundi 27 novembre 2017

jasmine testing uncaught error event handler

I am having difficulties testing a new package that I am writing with jasmine. The package idea is to create a listener for error or "uncaughtException" (in node) and give it a callback to work if there is such event.

describe('AllErrorHandler', function () {
    it('error is passed to the callback', function () {
        const error = new Error("testError");
        const callbackError;

        let errorHandler = new AllErrorHandler((error) => {
            callbackError = error;
        })

        throw error();

        expect(callbackError).toBe(error);
    })
})

How can I make this right?

Aucun commentaire:

Enregistrer un commentaire