Ember.js testing: follow the link

I am testing an Ember app and I have a link inside a table.

I can navigate to the link with the selector:

$('tr:nth-child(1) td:nth-child(3) a')

      

In my test I:

click($('tr:nth-child(1) td:nth-child(3) a'));

      

But after doing console.log(currentURL());

I am not on the link the above click should have clicked.

Should I be more specific about the link? Or am I using click wrong? Or is there another test helper I should be using?

+3


source to share


2 answers


click is an asynchronous method, you need to wait for it to complete before trying to view the results.

click($('tr:nth-child(1) td:nth-child(3) a'));
andThen(function(){
  console.log(currentURL());
});

      



or

click($('tr:nth-child(1) td:nth-child(3) a')).then(function(){
  console.log(currentURL());
});

      

0


source


I have this exact problem. In my Ember app, I can click on the tag and the modal dialog appears as expected. In the test I am writing for this modal, nothing seems to work. I can print

Ember.$('#id-of-tag').click();

      



in the JS console and the modal appears. I put this in a test and nothing happens. I tried to click (find ('# id-of-tag') [0]) too.

We are using Ember 2.7.3, but will soon be switching to 2.12.

0


source







All Articles