I am kinds of stuck. Here is what we are doing.
We have written angular code in 2.0 style where our app.js ahs the magic to convert components in directive and controller which is little complex.
Now I have to write test cases using karma & jasmine and we have create a framework for that but it doesn't work if I call our angular code. If I remove app.js from the angular code then I can reach to the class function, but as I add our app.js it give me errors like
Chrome 46.0.2490 (Windows 7 0.0.0) ERROR
Uncaught Error: Bootstrap's JavaScript requires jQuery
even though the kquery is already loaded.
or
22 10 2015 14:31:34.895:DEBUG [web-server]: serving (cached): /app/vendor/angular/angular-aria.js
Chrome 46.0.2490 (Windows 7 0.0.0) ERROR
Uncaught TypeError: Cannot read property 'module' of undefined
But if I write a small class/component everything works fine.
Has anyone did this(coding in 2.0 style) and written test cases for that.
If yes can you please help me what I should be doing or not doing.
Thank you
Manish
Related
I've got some issue for 2 days, it's getting on my nerve, if someone now how to fix this it will be very helpfull :
I've got a ionic 1 project, that I have to do some update, but nothing seems to work...
when i do ionic serve, and i look the console of the navigatori got :
Uncaught TypeError: angular.module(...).info is not a function
and
ReferenceError: Connection is not defined
at Object.isOnline
i'm stuck on the entry page and ng-src ng-click seems to not working.
I've look many post but nothing seems to resolve my problem.
Not all your angular scripts are the same version. .info was introduced recently, you might have angular files with different version.
Refer to related angular issue.
https://github.com/angular/angular.js/issues/15786
I got something like this :
Uncaught TypeError: angular.module(...).info is not a function
at angular-resource.js:445
at angular-resource.js:858
angular-resource.js:445:
angular.module('ngResource', ['ng']).
info({ angularVersion: '1.6.4' }).
provider('$resource', function ResourceProvider() {
var PROTOCOL_AND_IPV6_REGEX = /^https?:\/\/\[[^\]]*][^/]*/;
at angular-resource.js:858:
})(window, window.angular);
It appears that I can't ionic serve, that app, but I can cordova build android, on the computer that has develops it , but not on my computer which I develops ionic 2 project.
I don't know if this is from my npm, node, cordova version or if is something completly diferent.
I get this error running scripts/test.bat via console
Chrome 48.0.2564 (Windows 7 0.0.0) ERROR
Uncaught TypeError: Cannot read property 'module' of undefined
I am under Windows 7 as you can notice and using Angular Seed.
It seems like you've missed loading angular-mock library before listing test files in karma configuration under files:[] section. You need angular-mock library loaded before listing any test files. Beware that angular-mocks library in turn expects angular.js to be loaded before it.
refer: https://docs.angularjs.org/api/ngMock
I have got some angular services and a simple test, which tests that 1 method returns an instance of some type.
When I run it in WebStorm with PhantomJS and Chrome
"browsers": ["PhantomJS", "ChromeCanary"]
All tests are passed in chrome but in PhantomJS some tests will pass, but the test mentioned above produces the type error. (Not the test, but the code which is being tested by the test)
TypeError: 'undefined' is not a function (evaluating 'this._decorateParent.bind(this)')
<... other info>
Sure, I can mock out some dependencies and it will help. But I want to know what is the reason for such behaviour.
angular.js v1.3.14
karma v0.12.32
PhantomJS v1.9.8
Update to PhantomJS 2 which is the easiest way to solve this. PhantomJS 1.x is based on a 4 year old fork of QtWebKit which didn't support Function.prototype.bind at the time. Usually a shim is required to make that function known to PhantomJS, but this might be hard to impossible to do for karma.
If you want to try it with a shim, this one has always worked for me.
I have a small app that I have been working on the UI with the client. I am using TypeScript and Angular write the client code. I created a bar bones controller to deliver hard-coded data to the UI for layout purposes and it has been working fine in Chrome and Firefox.
Now that I am ready to start adding business logic I want to implement testing, so I installed karma (which has been challenging to say the least). When I run the code with karma using the Chrome browser I get a "function is undefined" error on a function exported from a TypeScript module that still works just fine when I use Chrome outside of karma (in WebStorm). The property is there, but the defined function is not.
The js generated code seems classic and conventional to me.
Can someone tell me why the code behaves differently under karma?
When I run the code with karma using the Chrome browser I get a "function is undefined" error on a function exported from a TypeScript module that still works just fine when I use Chrome outside of karma (in WebStorm). The property is there, but the defined function is not
Mainly just ensure correct order of file (script) loading.
I am getting an error when i try running phantomjs via this stack: rails (3.2.11), rspec (2.12.2), capybara (1.1.4), poltergeist (1.0.2), phantomjs (1.8.1)
and angular.js (1.1.2).
I have many specs that run fine on this stack, without angular. But on a test page where I initiate angular, I get the follow error. When I run the specs using selenium driver, they pass.
{"name"=>"visit", "args"=>["http://127.0.0.1:57124/pages/angular"]}
{"response"=>{"status"=>"success"}}
{"name"=>"find", "args"=>["./descendant-or-self::*[contains(normalize-space(.), 'Hello')]"]}
{"error"=>{"name"=>"Poltergeist.JavascriptError", "args"=>[[{"message"=>"TypeError: 'undefined' is not an object (evaluating '$lastDestination.offset().top')", "stack"=>"TypeError: 'undefined' is not an object (evaluating '$lastDestination.offset().top')
at http://127.0.0.1:57124/assets/application.js:13100
at http://127.0.0.1:57124/assets/application.js:3046
at http://127.0.0.1:57124/assets/application.js:2722"}]]}}
This occurs even on the most bare bones content, only without any other ng directives (no controller instantiated etc), eg
<div ng-app>
<h1>Hello</h1>
</div>
The spec looks like
describe 'ng_posts', type: :request, js: true do
it "should load page" do
visit '/pages/angular'
page.should have_content('Hello')
end
end
This appears to be a phantom.js bug because the page loads in the browser (no errors in js console) and the specs run with Selenium. Is this a known issue? Can i get past it? Thanks.
Jon
nevermind.
Turns out it was a bug in another library, zurb-foundation (alternative to twitter bootstrap) which was fixed a week ago but the gem update didnt have it yet. Updating Gemfile as follows fixed it.
gem 'zurb-foundation', github: 'zurb/foundation'