-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Karma as end to end test runner #2785
Comments
Currently, Karma isn't really designed for end-to-end testing. However, it is in the backlog to integrate web driver support. For more information, take a look at #413. |
@arqex What you were doing is including karma into your app, which is only good for single page applications (ajax, socket.io). By a regular web application your tests will break by sending a form or following a link. I am not sure whether testing the production server with mydomain.com is a good idea. Maybe you can measure loading speeds with it, but for feature testing it is a lot better to run the app locally for example in a docker container. update: |
Meanwhile I started an end to end testing library which supports Karma: https://github.com/inf3rno/e2e and uses client side scripting. I ended up with |
Hey guys!
I love the way karma works, and I am decided to use it as my end to end test runner and get rid of selenium, its asynchronous tests and the way it got stuck without any clear reason.
I already have some code to show, let me explain some context:
The tests are running inside of my app, let's say in
mydomain.com
.Karma will be running in my computer or any CI environment, like Bamboo, Travis or Codeship, so it will be able at
localhost:9876
.This domain mismatch is an issue that can be avoided not using iframes for the testing, and relaxing karma's server
Access-Control-Allow-Origin
, this is a piece of thekarma.conf.js
file:And now I need to load karma's environment in my app, and to do so I have created a small script. It works:
If I add this script to my page and start karma server, the tests are run when I open my website, and it works! I can start clicking here and there and check the results of my tests interactions, but it's so hacky.
There are so many hacky parts, that maybe you can help me to make it better:
http://localhost:9876
and I don't need it anymore. It make the tests fail because they are not in the proper context. It would be great to be able of configure a way of start the browser with the URL of my site:mydomain.com/?tests=1
.mydomain.com
, it should always point to Karma's server. You see I fix it addingkarma.socket.io.uri = karmaURL
after I load Karma, but Karma still tries to connect to thews
inmydomain.com
once.debug.html
. And then useseval
. Is there anything hackier than usingeval
? Should be there something simpler and safer to get the config?window.__karma__.scriptUrls
with the scripts, karma tries to load them automatically, but it was returning some error, so the script loads them by itself.Any help on how to improve the code, or doing it in a more standard way is welcome.
The text was updated successfully, but these errors were encountered: