Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Angular e2e tests with Karma don't and can't use the <code>JASMINE</code> adapter. Instead you have the <code>ANGULAR_SCENARIO_ADAPTER</code> which has a similar feel to writing Jasmine tests.</p> <p>All commands in the adapter's <a href="http://docs.angularjs.org/guide/dev_guide.e2e-testing#api">API</a> are asynchronous anyway. For example <code>element('#nav-items').count()</code> doesn't return a number, it returns a <code>Future</code> object. <code>Future</code> objects are placed in a queue and executed asynchronously as the runner progresses. To quote the <a href="http://docs.angularjs.org/guide/dev_guide.e2e-testing#api">API docs</a>:</p> <blockquote> <p><strong>expect(future).{matcher}:</strong></p> <p>[...] All API statements return a <code>future</code> object, which get a value assigned after they are executed.</p> </blockquote> <p>If you need to run your own asynchronous test code, you can extend the adapter's DSL, this is easier than it might sound. The idea is that you return your own <code>Future</code> which can be evaluated by a matcher such as <code>toBe()</code>. There are some examples on how to do this in <a href="https://gist.github.com/vojtajina/1840093">the e2e-tests.js Gist from Vojta</a>. Just remember to call <code>done(null, myRetrunValue);</code> when your test code is successful (<code>myRetrunValue</code> is the value evaluated by your matcher). Or <code>done('Your own error message');</code> if you want the test to fail.</p> <p><strong>UPDATE: In response to question below.</strong> To simulate a login, first add a function called <code>login</code> to the <code>dsl</code>:</p> <pre><code>angular.scenario.dsl('login', function() { return function(selector) { // @param {DOMWindow} appWindow The window object of the iframe (the application) // @param {jQuery} $document jQuery wrapped document of the application // @param {function(error, value)} done Callback that should be called when done // (will basically call the next item in the queuue) return this.addFutureAction('Logging in', function(appWindow, $document, done) { // You can do normal jQuery/jqLite stuff here on $document, just call done() when your asynchronous tasks have completed // Create some kind of listener to handle when your login is complete $document.one('loginComplete', function(e){ done(null, true); }).one('loginError', function(e){ done('Login error', false); }); // Simulate the button click var loginButton = $document.find(selector || 'button.login'); loginButton.click(); }) }; }); </code></pre> <p>And then call:</p> <pre><code>beforeEach( function() { expect( login('button.login') ).toBeTruthy(); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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