angulartics: unit tests fail when adding angulartics
I use karma for unit tests and I added angulartics… I changed nothing on my tests… I load this files in karma.conf.js:
'public/assets/components/angular/*.min.js',
'public/assets/components/angular-translate/angular-translate.min.js', // load in right order
'public/assets/components/angular-*/*.min.js',
'public/assets/components/angulartics/src/angulartics.js',
'public/assets/components/angulartics/src/angulartics-ga.js',
'public/assets/javascripts/app/app.js',
And the strange thing is, that I don’t get a specific error just 1 test FAILED with this message:
Some of your tests did a full page reload!
When I comment out the failing test, another one fails saying the same error message… I have no clue what is happening there… I use spyOn($location, 'path');
in some of my tests, has that something to do with it?
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 22 (2 by maintainers)
+1, $analyticsProvider.firstPageview(false);
Works great, I was getting Error: “Define sp” and this was causing further errors . This happens because we added a script block “var sp = …some… function();” in index.html for angulartics.splunk and when karma runs unit test this becomes undefined and that was causing whole test to fail. Adding just a sp variable in unit test under describe works great even I don’t need turn off firstPageview.
Thanks everyone for the discussion this helped a lot to find and fix my issue.
Thanks, it solved my issue too