Background: I'm trying to move this package Moment-recur from Bower to NPM in our Angular 1.5 app and having some trouble. The package depends on Moment and extends its function as
moment.recur = function(start, end) {
// If we have an object, use it as a set of options
if (start === Object(start) && !moment.isMoment(start)) {
return new Recur(start);
}
// else, use the values passed
return new Recur({ start: start, end: end });
};
This is what I did: Uninstalled the package from bower, installed through npm and updated index.js where the package is referenced:
From:
window.moment = require('moment');
require('Bower_Components/moment-recur/moment-recur.js');
To:
window.moment = require('moment');
require('moment-recur');
Problem: When I run our unit tests (karma), all the tests referencing recur function are breaking. The error I see is:
TypeError: moment(...).recur is not a function
I included console log on the Moment-Recur package's js file and could see that when I run the app. However, I don't understand why recur function is not available on moment.
I'm lost here and don't know how to figure out the cause. Let me know if you need me to post any other configuration settings from the app.