Ember test-helper 'visit' only works on root path

I have Acceptance tests working with the root url i.e. visit(‘/’) fine.

But when I try to visit another url, both Chrome and Phantomjs give me - “Error: Assertion Failed: You have turned on testing mode, which disabled the run-loop’s autorun. You will need to wrap any code with asynchronous side-effects in an run at http://localhost:7357/assets/vendor.js, line 17159”.


import Ember from "ember";
import startApp from '../helpers/start-app';
var App;

module('AcceptanceGear', {
    setup: function() {
        App = startApp();
    },
    teardown: function() {
        Ember.run(App, App.destroy);
    }
});

//this gives the error
test('GearTest', function() {
   visit('/gear');
    andThen(function() {
        equal(currentPath(), 'gear');
    });
});

//this works mostly fine
test('GearListMenu', function() {
    visit('/');
    andThen(function() {
        equal(currentPath(), 'index', 'path is root index');
        var gearNav = $('nav li a').filter("a:contains('Gear')");
        //gives a current path as 'loading' in Phantomjs, fine in Chrome
        click(gearNav);
        andThen(function() {
            equal(currentPath(), 'equipment.index', 'path is equipment.index');
        });
    });
});

Ember: 1.8.1 Ember-cli version: 0.2.0 node: 0.10.37 npm: 2.7.0

I am upgrading an app from the 0.1.12 up to current (at the time of this posting that is 0.2.6) and when I hit 0.2.0 and experienced a similar problem. I got a few minor “deprication” breakage points in the app and test failures with them which, when remedied by updating the code, instead of running green, just “switched” from the general error output from the “deprication” - to the infamous “you have turned on testing mode” … “run-loop autorun disabled”/“wrap in a run” error. This is now caused by so much as a visit() any further past root, which matches what you have …have you experienced any resolution on this as of yet?

Same issue here. I’ve got a few awaited promises in my routes model hook before returning (using babel’s async/await with regenerator) so I don’t know if that’s at all significant.

Here’s the model hook:

   async model(params) {
    const {location, date} = params,
          currentDate = moment(date),
          locations = await this.store.findAll('location');

    console.log('locations', locations);

    const sittings = await this.store.query('sitting', {filter: {date, location}, include: 'participants'}),
          casesBySitting = await* sittings.map(async item => await item.get('cases').toArray());

    // This flattens the nested array structure that we get from map above
    const cases = Array.concat(...casesBySitting),
          currentLocation = await this.store.find('location', location);

    return {
      cases,
      currentLocation,
      currentDate,
      locations
    }
  },

It’s super ES6y, I know. But I don’t see any side effects at all, just a lot of promises. And then here’s my test.

import {
  describe,
  it,
  beforeEach,
  afterEach
} from 'mocha';
import { expect } from 'chai';
import Ember from 'ember';
import startApp from '../helpers/start-app';

describe('Acceptance: Change Location', function() {
  var application;

  beforeEach(function() {
    application = startApp();
  });

  afterEach(function() {
    Ember.run(application, 'destroy');
  });

  it('can visit /cases', function() {
    server.create('user', {id: 'USER01'});
    server.createList('location', 100);
    server.createList('case-matter', 1);
    server.create('sitting', {id: 'SITTING01', date: '2015-10-01', relationships: {
      cases: [
        {type: 'case-matter', id: 1}
      ]
    }});

    //console.log('record thing?', recordThing.name, recordThing.id);

    visit('/cases/1/2015-10-01');

    andThen(function() {
      expect(currentPath()).to.equal('cases.index');
    });
  });
});

I just don’t see what I’m doing wrong here. It must be something simple that I’m missing, but I feel like I’ve read everything I can find in regards to this issue and still can’t figure it out.

Any help would be greatly appreciated.

I think this might actually be related to my use of async/await and awaiting more than one promise in the model hook. I’m gonna re-write my async/await code to use then calls but it makes my code a bit more complicated which is unfortunate. I’ll see how that goes.