I have an angularjs app with some directives which make use of jquery and bootstrap components. So, in order to test the directives, I have defined the following order of files in karma.unit.conf.js:
files = [
JASMINE,
JASMINE_ADAPTER,
'app/components/jquery/jquery.js',
'app/scripts/vendor/bootstrap.js',
'app/components/angular/angular.js',
'app/components/angular-mocks/angular-mocks.js',
'app/components/angular-ui/build/angular-ui.js',
'app/scripts/app.js',
'app/scripts/**/*.js',
'test/spec/unit/**/*.js'
];
If I load first angularjs and angular-mocks and then jquery and bootstrap, the tests run and fail because angular uses its own jQLite. But if I change the order as I wrote up here then this is what I get:
I've found that it isn't jQuery what's causing the exception... it's bootstrap.js. If I comment the bootstrap.js line, the tests run (and fail, as expected because the bootstrap components never were loaded). If I load bootstrap as above (or in any other place before the tests) then I get this:
PhantomJS 1.8 (Linux) Directive: tkModal should make hidden element visible FAILED[39m
at /home/ir/work/campari/app/components/jquery/jquery.js:1763
at /home/ir/work/campari/app/components/jquery/jquery.js:2833
at /home/ir/work/campari/app/components/jquery/jquery.js:2850
at /home/ir/work/campari/app/components/jquery/jquery.js:2850
at /home/ir/work/campari/app/components/jquery/jquery.js:2850
...
at /home/ir/work/campari/app/components/jquery/jquery.js:2850
at /home/ir/work/campari/app/components/jquery/jquery.js:2850
at /home/ir/work/campari/app/components/jquery/jquery.js:2850
at /home/ir/work/campari/app/components/jquery/jquery.js:3656
at /home/ir/work/campari/app/components/jquery/jquery.js:648
at /home/ir/work/campari/app/components/jquery/jquery.js:270
at /home/ir/work/campari/app/components/jquery/jquery.js:3657
at /home/ir/work/campari/app/components/jquery/jquery.js:3664
at /home/ir/work/campari/app/components/angular-mocks/angular-mocks.js:1589
at /home/ir/work/campari/app/components/angular-mocks/angular-mocks.js:1627
The line at /home/ir/work/campari/app/components/jquery/jquery.js:2850
repeats endlessly about a 15k times before the test fails (it seems to be happening when jQuery tries to execute the internalData function at jquery.js:1763).
Any idea would be appreciated
Found the answer, it was a bootstrap issue in version 2.3.0, updating to 2.3.1 solved it. See https://github.com/twitter/bootstrap/issues/6835
Found the answer, it was a bootstrap issue in version 2.3.0, updating to 2.3.1 solved it. See https://github.com/twitter/bootstrap/issues/6835
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With