vendredi 11 décembre 2015

Qunit fail with TypeError: $ is not a function

I have a ember app. Everything works expect one acceptance test :

test('delete user 271', function(assert) {
  server.logging = true;
  server.create('user', {id: 271});
  visit('/users/271');

  andThen(function() {
    assert.equal(currentURL(), '/users/271');
    const deleteUSerButton = find(':button.delete-user');
    click(deleteUSerButton);
    andThen(() => assert.equal(find('.modal-body').text().trim(), 'Are you sure you want to remove this user ?'));
  });
});

But I get TypeError: $ is not a function : at didInsertElement (actionnable-modal.js:10)

export default Ember.Component.extend({
  didInsertElement() {
    jQuery.noConflict();
    let modalContainer = $('#modal-container .modal');
    modalContainer.modal();
    modalContainer.on('hidden.bs.modal', () => {
      this.dismiss();
    }); // line 10
  }
});

The problem the test fail randomly. I don't know why. I removed the /temp folder without success. It seems that jquery.noConflict() is a mess for my code but if I remove this line : TypeError: modalContainer.modal is not a function and it breaks my modal on my website.

Do you how I can fix this ?




Aucun commentaire:

Enregistrer un commentaire