Acceptance testing, websocket pending hangs andThen() waiting for pending to finish


#1

I’m starting for the first time in Acceptance testing my Ember application.

So I started from login with this:

test/acceptance/login-test.js:

import { test } from "qunit";
import moduleForAcceptance from "myapp/tests/helpers/module-for-acceptance";

moduleForAcceptance("Acceptance | login");

test("Should login", function(assert) {
  visit("/login");
  fillIn("input[type=email]", "user@email.com");
  fillIn("input[type=password]", "userpass");
  click("button[type=submit]");

  andThen(() => {
    assert.equal(currentURL(), "/");
    assert.equal(find("h1").text(), "Hello!");
  });
});

It never goes in andThen(), so it hangs on click("button[type=submit]");.

I understand why.

In my app/templates/index.hbs I have a component notifications which rely on a websocket which is constantly in pending in my single page application (if I open Chrome there is a pending websocket call…).

If I remove this component from my index.hbs everything works as expected.

After the login I should tell to andThen() helper to ignore the pending state of that service('notifications') which is constantly in pending state?

How to do?


#2

Hey uncle Sam !

Maybe this piece of documentation can help you:
https://emberjs.com/api/ember/2.14/classes/Ember.Test

I am personnally using the registerWaiter() API to make my tests wait for my CSS transitions. It sounds like the exact opposite of what you are trying to achieve, but I believe your solution may be somewhere is in this Ember.Test class… :wink:

Hope it helps, good luck!