wait for ajax call completed then run all test jasmine - karma-jasmine

I am using jasmine and karma in a simple javascript project with jQuery.
I want my messages are loaded from a json and then execute all the test cases.
it is not waiting for the message load and ended up with many errors.
urx.localeService.loadJson();
this method loads a json response and assign the object to window.urx.msg; which is being used in my test cases like
urx.emailVerification.fail();
expect($("#verifyEmailMsg").html()).toBe(urx.msg["tryAgain"]);
How can i resolve it?
In my application i have mechanism, when that messaged loaded i publish event and others subscribe to that and it works perfectly.

Related

Selenium not allowing non XHR requests

We have our selenium server (java) which is opening an electron app to test. During our tests, it seems to just lose the program/process control when we make any non XHR request i.e. any TCP request (via tools like serialport) or if we do a DNS lookup for an app. When the execution of such code happens, things just stop working (the code is async and never comes into the try catch block that is enclosing it) and the test fails.
Has anyone seen this type of issue before?

Does TestCafe end the node process once all tests are run? Reporter makes async calls and they never return

I'm making a custom reporter that uploads files to Slack, shares them and returns the file link to the reporter (to add to the Slack message) but when I try this out in a real test run, the async calls to upload the file and share fire but it looks like the node process ends before they can return and be processed.
I'm quite sure this is happening as this isn't a problem in the gulp test run (that mocks a TestCafe test run) as the reporter sends off a Slack message with all the async data appended to it successfully.
Any ideas? I'm thinking of adding another fixture to my test to wait for a specified time so that the calls complete and the message is able to be sent.

Is there a way to view PhantomJS console.log messages via Selenium/GhostDriver?

I'm using the Java bindings of GhostDriver to run Selenium acceptance tests against PhantomJS.
If one of the web pages requested by PhantomJS logs to the Javascript console via console.log, is there a way to capture or view those messages?
I'm guessing that the answer to this is forehead-slappingly simple but I can't work it out!
LogEntries logs = driver.manage().logs().get("browser");

AngularJS unit testing without relying on mocks for request data

I've finally got my AngularJS testing environment setup and I'm trying to test out to see if the pages on my application are working. This includes templates, routes, requests, directives and so on.
From what I've discovered, when testing out a working application it turns out that mocks are required to do most of the work. While this is nice, I would still like to test out actual templates and data from my application.
Whenever a GET call is made within my application, I get an error that looks like:
Unexpected request: GET application/templates/home.html
No more request expected
Error: Unexpected request: GET application/templates/home.html
Turns out that it can't download the request properly. Which is fine. From what I think is going on the testing runner (testacular) is unable to download the template file since it's on a different environment all together (no HTTP address provided). The only solutions I've come across on how to fix this are to stub the request with a mock using the $httpBackend service. While this is useful for certain situations, I want to fetch the actual data.
Any idea on how to fix this?
You probably want to write two different kinds of tests:
Unit tests with mocks to test components in isolation, things like controllers, directives, etc
e2e tests that run your full stack, including data from your own server.
These two kinds of tests each require a separate testacular configuration.
Angular provides support for navigating the test browser and interacting with your application, as a user would. The explanation and API is documented here: http://docs.angularjs.org/guide/dev_guide.e2e-testing
My testacular e2e config and explanation is posted here:
https://stackoverflow.com/a/13410567/1739247
The important part for running the tests against your own server is proxies, as explained in that post.

Does ExceptionHub break Selenium's wait_for_page_to_load command

I just added ExceptionHub (a javascript error tracking service) to our website, but all my selenium tests are failing now. When I look at the selenium output, it says it timed out in waitForPageToLoad command. If I run the test locally, I see that the page loads up fine, so I'm not really sure why selenium keeps waiting. Has anyone else managed to get ExceptionHub working with selenium?
I've seen similar problems with UserVoice. Often the rest of the page is loaded but still waiting for UserVoice and the test will time out.
It might help if you don't start loading ExceptionHub until the rest of the page is loaded. Of course that would mean you can't catch any javascript errors during page load...