Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm struggling to find references to back this up or explain a little more nicely, other than <a href="http://docs.angularjs.org/guide/dev_guide.e2e-testing" rel="nofollow">these docs</a> which don't have much info. Therefore this answer is mainly from memory of reading the relevant code.</p> <p>When you write a test in <code>ngScenario</code>, you are not writing a series of immediate actions as you would do in a unit test. What you are actually doing queuing up a list of commands to execute when the test starts.</p> <p>Methods that looks like normal jQuery functions, such as <code>text()</code> or <code>attr()</code> are actually part of <code>ngScenario</code>'s DSL and return future objects (meaning they will at some point execute and have the result of the call you wanted.)</p> <p><code>expect()</code> already knows this so waits for the result before comparing to your expected value. The code underneath, in your example, is reading directly and immediately so will see the future object.</p> <p>If you do need to read the element in this way I suggest looking at the <a href="http://docs.angularjs.org/guide/dev_guide.e2e-testing#example_conditional-actions-with-element" rel="nofollow"><code>query</code></a> function which should allow it. On the other hand if you need to just check the formatting of the string you can use <a href="https://github.com/pivotal/jasmine/wiki/Matchers" rel="nofollow"><code>toMatch</code></a> which <a href="https://github.com/angular/angular.js/blob/master/src/ngScenario/matchers.js#L27" rel="nofollow">has been implemented in <code>ngScenario</code></a> too.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload