Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma Runner > Loading bootstrap.js before angular and angular-mocks throws exception

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:

Edit:

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

Edit: Solved

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

like image 665
rvignacio Avatar asked Nov 12 '22 06:11

rvignacio


1 Answers

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

like image 199
rvignacio Avatar answered Nov 15 '22 11:11

rvignacio