Acceptance tests in Ember.js change the URL in the address bar

It was an annoying problem for several days. When I start trying to write acceptance tests for my Ember application, when I use the function visit(), the URL changes in the address bar of the browser, so when I change a bit of code and liveReload happens, it goes from my test page to any page that I said visit her in tests.

To troubleshoot, I'd ember newcreated a new application / home route and template and created an acceptance test for it, and it went fine without changing the URL in the address bar. I compared the code in tests/helpersand it is the same as tests/index.html.

I searched everything without meeting an answer. It was hard enough for me to check, but such problems are just tangential, but very annoying. If someone tells me why this is happening, I would be very grateful for the correction.

As an example, here is my one acceptance test. It passes, but the URL does change:

import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'star/tests/helpers/start-app';

var application;

module('Acceptance: AddMilestone', {
  beforeEach: function() {
    application = startApp();
  },

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

test('Adding milestones', function(assert) 
  visit('/projects/1234567/details');

  andThen(function() {
    assert.equal(currentPath(), 'project.details');
  });
});
+4
source share
1 answer

Look config/environment.jsfor a block like this:

if (environment === 'test') {
  // Testem prefers this...
  ENV.baseURL = '/';
  ENV.locationType = 'none';

  // keep test console output quieter
  ENV.APP.LOG_ACTIVE_GENERATION = false;
  ENV.APP.LOG_VIEW_LOOKUPS = false;

  ENV.APP.rootElement = '#ember-testing';
}

Is it installed ENV.locationTypein nonefor your environment test?

If not, are you changing locationTypeelsewhere in your application? Setting it to noneleaves only the address bar.

+6
source

All Articles