Broken with Angular 1.2.0rc-1
kburson opened this issue · 5 comments
Angular has moved the routeProvider out of the angular.js core and into it's own module. I have not fully investigated the differences, but in my project everything was working fine with 1.1.5, when I upgraded to 1.2 the midway tests broke.
Also, before I did not have to inject 'ngRoute' for my tests to work, but some of the comments I am reading on the web say this is now necessary. I tried it without success.
I am trying to read and learn how you implemented your testing framework to see if I can help, I am hoping that you can pinpoint this problem faster and provide a fix.
Hmmm, investigating: Added ngRoute to the app (since it was removed from angular.js 1.2, we now must manually include it in our files and our injection list.
Now getting the following error:
- "before each" hook Error: [ng:btstrpd] App Already Bootstrapped with this Element ''
For some reason when the test tries to create a new tester and register that tester with the app under test it passes the first time thru and fails the second, so something in the new Angular is holding onto state that the app has been bootstrapped.
Ouch! Anybody have any ideas?
Ach Tung! Found it...
fix(re-bootstrap): Throw an error when bootstrapping a bootstrapped element...
on july 24, a patch was made to throw an error if someone tried to bootstrap an app that was already bootstrapped.
In ngMidwayTester there is a method called to register an app
ngMidwayTester.prototype.register = function(name, module, callback) {...}
that calls
this.attach(testModuleName),
which in turn calls
angular.bootstrap(html, [name]);
So, with this new patch in place you can no longer call angular.bootstrap more than once, and in the midway tests I see it used in all the beforeEach() methods to standup the test app. This even fails if the register invocation is put in the before() method as opposed to the beforeEach(), thereby only calling once per fixture, yet the second fixture that loads up will fail for the same reasons.
Oy! How to solve this one? Please help, I'm over my head!
@kburson Did you manage to get something ? I get (obviously) the same error with the brand new 1.2.0-rc3.
I have the feeling that we can remove the call to angular.bootstrap in ngMidwayTester and use angular.mock.module to load our modules, which would be much more cleaner. I'll tell you more about my tests.
The latest code should work on 1.2 RC1 and higher (I tested it on both RC1 and RC3).
Just install using npm install ng-midway-tester
for now and load the file from node_modules/ngMidwayTester
.
Keep in mind that the new verison's API has changed. The README contains all the instructions you need.