Note that there are some explanatory texts on larger screens.

plurals
  1. POInconsistent results from karma e2e test runner. How can I debug?
    primarykey
    data
    text
    <p>I have a simple angular / requirejs / node project that loads correctly when viewed from a browser. I'm trying to get e2e tests with karma set up.</p> <p>I've copied all of the e2e configurations and directory structures from <a href="https://github.com/tnajdek/angular-requirejs-seed" rel="nofollow noreferrer" title="the angular-requirejs-seed">the angular-require-js seed</a> into my own project. Unfortunately, the tests in my own project give bizarre (and ever-changing!) results. Here's the stripped-down test I'm trying to run:</p> <pre class="lang-js prettyprint-override"><code>describe('My Application', function() { beforeEach(function() { browser().navigateTo('/'); sleep(0.5); }); it('shows an "Ask a Question" button on the index page', function() { expect(element('a').text()).toBe('Ask a Question'); }); }); </code></pre> <h1>Sometimes the test fails</h1> <p><code>Executed 1 of 1 (1 FAILED) (0.785 secs / 0.614 secs)</code></p> <pre><code>Firefox 22.0 (Mac) My Application shows an "Ask a Question" button on the index page FAILED element 'a' text http://localhost:9876/base/test/lib/angular/angular-scenario.js?1375035800000:25397: Selector a did not match any elements. </code></pre> <p>(but there ARE <code>a</code> elements on the page!)</p> <h1>Sometimes the test hangs</h1> <p><code>Executed 0 of 0</code>! In these cases the test-runner browser does show that it's trying to run a test, but it never completes:</p> <p><img src="https://i.stack.imgur.com/ZGEik.png" alt="It just stays like this forever"></p> <p>It just stays like this forever. My app <em>IS</em> displayed in the browser during this hang.</p> <h1>Without <code>element('a')</code> it always passes</h1> <p>The only way to get consistent results is to avoid <code>element()</code>. If I expect(true).toBe(true) then 1 out of 1 tests always pass.</p> <h1>How can I debug this?</h1> <p>I'm at a loss for how to move forward. The test browser is correctly <em>displaying</em> my app, with the relevant 'a' element and everything. The test runner itself seems to only sometimes recognize that it should be running something and NEVER finds the <code>a</code> element. Is there a way to step through the test running process? Is this a common problem that happens when [x] is misconfigured?</p> <p>Thanks for any suggestions!</p> <h1><code>karma-e2e.conf.js</code></h1> <pre><code>basePath = '../'; files = [ 'test/lib/angular/angular-scenario.js', ANGULAR_SCENARIO_ADAPTER, 'test/e2e/**/*.js' ]; autoWatch = false; browsers = ['Firefox']; singleRun = true; proxies = { '/': 'http://localhost:3000/' }; urlRoot = "__karma__"; junitReporter = { outputFile: 'test_out/e2e.xml', suite: 'e2e' }; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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