I find the benefits of having a dependency management system extend to testability because you can figure out which files need to be tested automatically and do on the fly unit tests of changed code as your work if you script it well. The only thing better than RequireJS that I've used in this regard is Closure Compiler, which gives you the ability to finely tune your dependency system to track changes and their impacts to other components and the tests that run against them.
More work to get this running, but the payoff is worth it for me. So on the one hand it can be tricky to get RequireJS running with your tests, but if you're willing to invest in scripting, it can be more testable and give you more control than without it. You just have to ask yourself if you're willing to invest in your build scripts. PS. I use mocha for my testing. Never tried Jasmine on a Requirejs system but I found it too much trouble to get karma to play nicely with RequireJS. On Fri, Dec 20, 2013 at 5:34 PM, Martin Atkins <[email protected]> wrote: > I work on an app (unfortunately not open source) that uses RequireJS with > Angular primarily as a dependency management system. (i.e. We're not trying > to do lazy-loading right now.) > > Our app consists of several AngularJS modules that are all rolled up into > a single top-level module. We have an AMD module per Angular module and > then an AMD module per component of a module. Our bootstrapping code > requires the AMD module containing the root module, which in turn depends > on the AMD modules for each sub-AngularJS module. Those sub-modules in turn > depend on the AMD modules for the services, directives, etc inside. > > Once RequireJS has taken care of resolving all of the dependencies, if > those AMD modules call angular.module and Module.service (etc), Angular can > be used as normal. > > When it comes to testing, we have a single non-AMD JS file that uses > 'require' to load up the root AMD module *and* the AMD module that contains > or reference all of the tests. Once again, once RequireJS is done with its > work all of the tests are registered in Jasmine and it just works. > > I guess the one "trick" here is that we still use the global 'angular' and > 'describe', 'it', 'expect', etc variables from AngularJS and Jasmine, so > those remain global even though our app is made of AMD modules. As long as > you have some code to kick off the RequireJS process it doesn't really > matter that everything's wrapped in define(). > > Each scenario is different of course, but there are enough distinct parts > to our app that I think RequireJS has been a net win for us. Once we got > over the hump of figuring out all of the above we've been able to build the > app from lots of small parts and let RequireJS take care of managing the > dependencies between them, which is a big win over manually handling > dependency management via explicit script tags. > > > > On Fri, Dec 20, 2013 at 5:19 PM, Danny Eck <[email protected]> wrote: > >> I'm just starting to evaluate integration with RequireJS and I'm >> concerned the benefits may not outweigh the cost. I want to speak in as >> general terms as possible here, because that's what I haven't (to my >> satisfaction at least) been able to scrounge from the interwebs. >> >> Integrating Require seems like it would have *major* negative >> consequences on complexity and testability. Can i still create angular >> modules by composition of submodules? (All the examples I've seen just have >> a single *main* module.) And how do I unit-test all this stuff when its >> wrapped in define()? >> >> Like i said i'm just getting started researching, but I'm leaning very >> heavily against using require in my case. I especially don't want to redo >> build configs, tests, and all that jazz. Am i overestimating the negative >> impacts here? Thanks. >> >> On Saturday, June 29, 2013 6:40:49 PM UTC-5, David Driscoll wrote: >>> >>> I was watching the meetup video on Angular 1.2 and beyond, and at around >>> 55:00, the question is asked about angularjs and requirejs. Misko and Brad >>> drop a bomb that RequireJS is going to replace angular.module, are there >>> any more details about how this integration will work? >>> >>> http://www.youtube.com/watch?v=W13qDdJDHp8&feature=player_ >>> detailpage#t=3301s >>> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "AngularJS" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/angular/4-otp3gTz5s/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/angular. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > You received this message because you are subscribed to a topic in the > Google Groups "AngularJS" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/angular/4-otp3gTz5s/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/groups/opt_out.
