1

I have a Portal application running on one port--http://localhost:10039. I am trying to unit test individual Ember.js applications, which are loaded into the Portal app via portlets.

What I'd like to be able to do is have those QUnit tests run against the full application, which is running on that other port I mentioned. However, Karma seems to not be fond of running the test suite on a port that isn't the same one on which the application is running.

For example:

test('Page loads in browser', function() {
  visit('/login').then(function() {
    ok(exists('#login-form'), 'Page loaded successfully');
  });
});

... launches Karma successfully on port 9876, but yields...

Page loaded successfully@ 42 ms
Expected: true
Result: false
Diff: true false 
Source: 
    at http://localhost:9876/absolute/Users/me/Sites/app/node_modules/qunitjs/qunit/qunit.js:1933:13
    at http://localhost:9876/base/tests/unit-tests.js:9:8
    at isolate (http://localhost:9876/base/bower_components/ember/ember.js:36720:15)
    at http://localhost:9876/base/bower_components/ember/ember.js:36703:16
    at tryCatch (http://localhost:9876/base/bower_components/ember/ember.js:45817:16)
    at invokeCallback (http://localhost:9876/base/bower_components/ember/ember.js:45829:17)

Is it possible to run my test suite on, say, http://localhost:9876, and have it run its tests against another website/port http://localhost:10039?

The closest I could come to an answer was Karma proxies, though the proxy seems to have no effect. Karma is still running its tests against links relative to its own port 9876.

I would like to add that I am open to other testing frameworks if this can only be done elsewhere--Jasmine, Mocha, etc.

Thanks!

DerektheDev
  • 93
  • 1
  • 9

1 Answers1

0

karma is intended for running unit tests, so the code will be loaded in karma client (localhost:9876) and test cases executed there.

If you are planning to run certain end to end tests with your portal application, you could look into alternatives like selenium. In fact, your test above (testing for successful page loading) is a good fit with selenium.

cactusme
  • 143
  • 7
  • In regards to your first statement, does this mean that I cannot run an external website through Karma? What about testing through an iFrame? I know, that's very kludgy, I just want to know if my thinking in the original question would be considered **discovering the power** of Karma versus **abusing** the tool with patchy, unsupported practices. – DerektheDev Apr 06 '15 at 22:33