lundi 22 juin 2015

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

This has been an annoying problem for days now. As I start to try to write acceptance tests for my Ember app, when I use the visit() function, the URL is changed in the browser's address bar, so when I change a bit of code and the liveReload happens, it navigates off my test page to whatever page I had told it to visit in the tests.

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

I've searched all over without coming across an answer. It's been hard enough for me to grok testing, but problems like this are just tangential, but very irritating. If anyone has a tip as to why this is happening, I'd be extremely grateful for a fix.

As an example, here's my one acceptance test. It passes, but the URL actually changes:

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');
  });
});




Aucun commentaire:

Enregistrer un commentaire