Amir T
Amir T

Reputation: 2758

EmberJS Testing reset not fully reseting or async issue

If I change the order of my Ember/Qunit tests, they pass. Why is that, or what can I do to avoid it?

Edit: I notice that the Qunit tests run in a more or less random order (whichever is ready first?), regardless, when TEST B follows TEST A, it is failing.

It seems that either App.reset() isn't fully resetting or there is some async issue I'm not seeing.

spec

module("Integration Tests", {
  setup: function() {
    console.log('reset');
    Encompass.reset();
  }
});

test("TEST A", function() {
  visit("/workspaces").then(function() {
    ok(true);
  });
});

test("TEST B", function() {
  visit('/workspaces/1/submissions/1').then(function() {
    ok(find('li[title="Kyle Folder 1"]').length, "the folder is there");
  });
});

I have both versions of the test online.

This is using the fixture adapter with a bunch of models (possibly not all the correct relations, but I still expect the tests to be consistent regardless of order)

Upvotes: 4

Views: 979

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

App.reset() resets the ember application itself, it doesn't reset Ember Model/Data.

You'll need to use unloadAll for Ember Data:

this.store.unloadAll('post');

For Ember Model you'll use clearCache:

App.Post.clearCache();

Have you tried allowing the visit to resolve before running ok on test A?

test("TEST A", function() {
  visit("/workspaces").then( function(){
    ok(true);
  });
});

Upvotes: 2

Related Questions