3

I'm currently trying to get started with writing tests (I know, I know, I should have done that before I wrote the application), but I'm currently stuck trying to test the login functionality.

Here is the test:

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

describe('Integration: Authentication', function() {
  var application;

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

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

  it('User can sign in', function() {
    visit('/signin').then(function() {
      fillIn('input[name="identification"]', 'username');
      fillIn('input[name="password"]', 'password');
      click('button[type="submit"]');
      andThen(function() {
        expect(currentPath()).to.equal('welcome');
      })
    });
  });
});

Im getting this error:

Error: Assertion Failed: calling set on destroyed object (http://localhost:7357/a ssets/vendor.js:19994)

Does anyone know how to solve this?

Thanks

Frank Jensen
  • 367
  • 5
  • 14
  • Can you provide the code you are trying to test? – QuantumLicht Sep 01 '15 at 14:49
  • 2
    Just a wild guess, but maybe you're trying to call set on a destroyed object. The most common case is an `Ember.run` scheduling something to be run in the future, and the object, such as a component, is torn down before it runs. The ways to avoid this are (1) check for the object being destroyed before calling set on it or (2) cancelling the `Ember.run` request in the object's `willDestroy` hook. –  Sep 01 '15 at 17:33
  • Im wondering if its because that the 'content' has changed and so the binding is 'gone'. We start on a signin page and this is the base of the test, but when clicking the login button, the page and state of the application changes. Could this be the issue? – Frank Jensen Sep 02 '15 at 08:01
  • @QuantumLicht it's a basic simple auth implementation. – Frank Jensen Sep 02 '15 at 08:01
  • having the same problem here, any fix? – Mohamed El Mahallawy Nov 11 '15 at 21:04
  • @torazaburo - It would be handy to know which object it is trying to destroy. – Deej Dec 09 '15 at 17:00
  • If you run the tests in the browser (`ember test --screen`), you can see the screen trace and track it down. –  Dec 09 '15 at 17:02
  • Sorry, that should be `ember test --server` obviously. –  Dec 09 '15 at 17:09
  • 1
    Possible duplicate of [Uncaught Error: Assertion Failed: calling set on destroyed object](http://stackoverflow.com/questions/25141822/uncaught-error-assertion-failed-calling-set-on-destroyed-object) – pjmorse Jan 06 '16 at 19:06

0 Answers0