4
votes

I'm trying to setup ember-testing with QUnit to test my Ember.js application following these blog post: Getting started with integration testing ember.js using ember-testing and qunit-rails

My problem is, that every time I try to visit a route with ember-testings visit helper, the visit(<route>).then promise doesn't get called, but the correct view is rendered.

Here my current Ember.js setup: (I also tried with beta)

  • Ember : 1.3.0-beta.1+canary.8f5b6e20
  • Ember Data : 1.0.0-beta.4+canary.e7996c4d
  • Handlebars : 1.1.1
  • jQuery : 1.10.2

EDIT 1:

QUnit only shows, that the test is running, no failure or success message.

Test:

module("Ember.js Library", {
  setup: function() {
    Ember.run(App, App.advanceReadiness);
  },
  teardown: function() {
    App.reset();
  }
});

test("Check HTML is returned", function() {
  expect(2);
  visit("/").then(function() {
    ok(false, "Show me an error!");
  });
});

Test setup (test_helper.js):

document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
document.write('<style>#ember-testing-container { position: absolute; background: white; bottom: 0; right: 0; width: 640px; height: 384px; overflow: auto; z-index: 9999; border: 1px solid #ccc; } #ember-testing { zoom: 50%; }</style>');

App.rootElement = '#ember-testing';
App.setupForTesting();
App.injectTestHelpers();

EDIT 2:

QUnit seems to work correct. If I use the following Test, then QUnit test runner shows the correct failures. But if I include the assertion in the promise like above, then QUnit shows the test as running, but the test seems not to stop.

test("Check HTML is returned", function() {
  expect(2);
  ok(false, "Show me an error!");
});
2
Can you show your test code, and the code being tested?Marcio Junior
I added my test and test-setup code. In the test I call index route /, but I also have tried other routes like /login. In case of login, the login view is rendered, but the test doesn't show success or failure message.kunerd

2 Answers

3
votes

The problem was in Ember-Simple-Auth plug-in, there was a bug in the version I used. I upgraded and now everything works as expected.

@kingpin: Thank you for your minimal working example, after comparing it to my code I realized, that something else must be the cause of the hang up and so I found the plug-in mentioned above.

1
votes

You're missing the qunit div, add this guy with your other document.writes

document.write('<div id="qunit"></div>');

http://emberjs.jsbin.com/inATaNE/1/edit