I have been working with the kriskowal/q module to create a promise, but I am encountering an issue where it does not enter any function paths - neither the happy path nor the error path.
Below is the class where I create the promise:
var Q = require('q');
var Test = function () {
};
Test.prototype = (function () {
var testt = function () {
var deferred = Q.defer();
var x = 5;
if (x === 5){
deferred.resolve('resolved');
}else{
deferred.error(new Error('error'));
}
return deferred.promise;
};
return {
testt : testt
}
}());
module.exports = Test;
This is how I am attempting to use the promise:
var Test = require('../src/js/test.js');
describe("Test", function () {
"use strict";
var test = null;
beforeEach(function () {
test = new Test();
});
it("should return the promise", function () {
test.testt().then(
function (a) {
console.log(a);
},
function (b) {
console.error(b);
}
);
});
});
Since this is a jasmine test class, the logic inside the 'it' function demonstrates how I am using the promise created in the 'testt' function. For more details, I have included the full code snippet.
Issue: The promise does not output either variable 'a' or 'b'.