I have encountered an error while writing a Mocha test for a module in my express application. I am unsure about how to resolve this issue.
Here is the test:
describe('userController', function() {
describe('post -> /create', function() {
it('A user should be created', () => {
var testRequest = {
body: {
password:"pass1",
email:"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ea9e8f999eaa87fc4898587">[email protected]</a>",
username:"user1",
}
};
database.registerUser(testRequest, (callBack) => {
new User({email:"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d1a5b4a2a591bcb4ffb2bebc">[email protected]</a>"})
.fetch()
.then((model) => {
assert.equal(model.get('password'), testRequest.body.password);
})
.catch((err) => {
assert(false);
});
});
});
});
});
The Error:
Unhandled rejection AssertionError: false == true
at User.fetch.then.catch (/home/shanedrafahl/code/MyRentalServer/myRental/test/test.js:72:17)
at tryCatcher (/home/shanedrafahl/code/MyRentalServer/myRental/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/shanedrafahl/code/MyRentalServer/myRental/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/shanedrafahl/code/MyRentalServer/myRental/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/shanedrafahl/code/MyRentalServer/myRental/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/shanedrafahl/code/MyRentalServer/myRental/node_modules/bluebird/js/release/promise.js:689:18)
at Async._drainQueue (/home/shanedrafahl/code/MyRentalServer/myRental/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/shanedrafahl/code/MyRentalServer/myRental/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/shanedrafahl/code/MyRentalServer/myRental/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
I would appreciate any guidance or insight on why this error is occurring and how I can resolve it.