I am using the end to end test specified in the Github intro to Karma. I was able to run runner.html in Chrome pointing to my localhost '/test/runner.html' and all the test ran successfully. But when I run the same tests in IE10 and all tests failed with following errors
65ms
browser navigate to '../../app/index.html'TypeError: Object doesn't
support property or method 'resumeBootstrap' at Anonymous function
(/test/lib/angular-scenario.js:26240:11) at
dispatch (/test/lib/angular-scenario.js:3063:6)
at eventHandle
(/test/lib/angular-scenario.js:2681:5)
Is it because of limitation of IE?
Thanks
this may help, workaround for the same is also specified in it, and you can more dig into the same too if you want.
1.1.4 scenario runner does not work in IE (8 -> 10)
Related
In my AngularJs application I'm using Jasmine and Karma for my unit tests.
Recently, after a chrome update (now on 72.0.3626.81) my unit tests starting failing locally (with no change to code). I believe the error is a result of my coverage tool Instanbul.
Sometimes the error appears like this:
An error was thrown in afterAll Uncaught ReferenceError: __cov_iuQO6FdumXRPLjSMopb0JQ is not defined thrown
Other times it will appear within a specific unit test (not sure why).
I searched my application and the only file this __cov_ variable could come from is the return of a function within the Instanbul package, generateTrackerVar() within instrumenter.js.
As no code changes were made I assume that the issue is with the new version of Chrome, perhaps the security settings.
My question what permissions would karama-coverage/istanbul require? OR if anyone suspects the issue isn't security based, then what could be causing this error?
Thanks
EDIT:
I have tried to disable web security in my gulpfile like so:
browsers: [ 'Chrome_without_security' ],
customLaunchers: {
Chrome_without_security: {
base: 'Chrome',
flags: ['--disable-web-security']
}
},
But this didn't solve the issue. Is there a way to set the chrome version in this config?
I managed to solve this by figuring out the hashcode after __cov_ was related to a test file that was throwing an error. I don't know why the error didn't just appear as it normally would, that will be another problem to solve.
For now I managed to figure out the file by logging in instrumenter.js within the instanbul package. Then by removing my coverage tool I figured out the source of the issue. Simply removing the coverage tool would give me a different error but not tell me which file so I needed to do both.
I am attempting to run protractor tests locally using chrome but in headless mode, I have seen the docs and added the appropriate options to my config file:
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
chromeOptions: {
args: [ '--headless', '--disable-gpu', '--window-size=800,600' ]
}
}
Upon running, I encounter the following error:
[1009/122000.081:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
I tried removing the --disable-gpu flag as I read this may not be needed in future version of Chrome. I currently have latest Chrome installed (69.0.3497.100) and am using windows 7.
What do I need to do in order to get the tests running in headless mode? My intention is to check I can run in headless mode fine locally and then I want to get it running also in Chrome headless mode on a linux Jenkins node, where we are currently using XVFB but its proving to be too flaky with timeouts in tests for example.
Thanks
EDIT
With regards to others marking this as a duplicate - I should have said that my tests fail to run when I attempt to use the headless option, without the chrome options set, Chrome launches as expected and the test run and pass successfully.
My tests fail with no such element found type errors and if I view the screenshots taken on the failures, I just see a white square inside a black background (probably as per the --window-size option I was setting)
As you mentioned you are using Chrome headless mode on a linux Jenkins node you need consider a few factors as follows:
--disable-gpu
When Headless Chrome was first released as GA (General Availability) by Google Team the article Getting Started with Headless Chrome mentioned that :
--disable-gpu \ # Temporarily needed if running on Windows.
A note was added as :
Right now, you'll also want to include the --disable-gpu flag if you're running on Windows.
As per the discussion Headless: make --disable-gpu flag unnecessary it was clear that :
The --disable-gpu flag is no longer necessary on Linux or Mac OSX. It will also become unnecessary on Windows as soon as the bug SwiftShader fails an assert on Windows in headless mode is fixed.
You can find a detailed discussion on What happened under the hood in the discussion ChromeDriver showing Lost UI Shared Context
So as a first step you need to remove the argument: '--disable-gpu'
flaky tests
You seem to be executing your tests with the argument --window-size=800,600 which implies a reduced Viewport.
In order to utilize the maximum possible Viewport you must initialize the Chrome Browser in maximized mode through the argument: 'start-maximized'
angular
From Angular perspective, you can avoid timeouts by using the proper expected_conditions. You can find a detailed discussion about different expected_conditions in WebDriverWait not working as expected
--headless
Finally, I am not sure what exactly you meant as in ...my tests fail to run when I attempt to use the headless option, without the chrome options set.... Perhaps the argument '--headless' can be invoked only through chromeOptions and no other alternative.
I have the same error while running [1010/161441.019:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
but my test runs perfect.I have you referred this https://gist.github.com/cvuorinen/543c6f72f8ec917ebfd596802d387aa3
I hope this below may help you
https://cvuorinen.net/2017/05/running-angular-tests-in-headless-chrome/
https://developers.google.com/web/updates/2017/04/headless-chrome
I have tried both phantomJS and chrome while testing in karma but I am not able to get the advantages of phantomJS over chrome.
Whats the use of phantomJS over chrome.
Why to use phantomJS when we can use chrome
One reason is that you don't need all the time to have the browser when testing, for example when there is a service to be tested - you don't use protractor at all because there are no html elements you need to test, but nevertheless you need to run those tests with Karma. Here comes the usage of phantomejs.
Additionally when running tests, with phantomejs you can do screen capture of the running process - can you do that with chrome?
Check in more details the possiblities of phantomejs and you will see more differences in when/where phantome can be used over chrome.
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 working on an angularjs project where if a user scrolls on an element, the element calls scrollTop() to determine if another method should be called.
I wrote this sinon.stub
scrollTopStub = sinon.stub($.fn, "scrollTop").returns(50);
This is the validation
expect($.fn.scrollTop.calledOnce).to.be.true;
The tests pass when I run them using karma, mocha and chrome.
However, when I run the tests headless the sinon stub is never called.
Any thoughts?
I know this is an old question. But if someone bumps into this: this is probably a completely different issue. I run into a similiar one once almost been driven crazy by cryptic and misleading errors when running with phantomjs (I assume this is the headless browser) - in the end I found out that Phantomjs doesn't support bind (and some other es5 methods So code using them would fail. just adding es5 shim to the test index.html (or karma.conf or.. ) file solved the problem. Since I used sinon.js with phantomjs in another project I know this can work correctly