Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically loaded test scripts disrupts test execution order
    primarykey
    data
    text
    <p>I'm running a set of QUnit tests that use module level <code>setup</code> and <code>teardown</code> methods. I've noticed that using <code>start()</code> and <code>stop()</code> inside my tests appears to disrupt when these get called, which causes problems as certain items made available in my setup are not available to some tests that run.</p> <p><em>Edit</em>: I've noticed that this happens exclusively when I load my test scripts programmatically (I'm using a script loader: <a href="http://labjs.com/" rel="nofollow">LABjs</a>). I have modified the subject and content of this question accordingly. I am loading tests like this:</p> <pre><code>$LAB.script('/static/tests.js') </code></pre> <p>Still not sure why this happens.</p> <p>Here's a sample of my test module:</p> <pre><code>module('Class Foo', { setup: function() { console.log('setup called'); }, teardown: function() { console.log('teardown called'); } }); test('Test1', function() { stop(); console.log('test1'); ok(true); start(); }); test('Test2', function() { stop(); console.log('test2'); ok(true); start(); }); test('Test3', function() { stop(); console.log('test3'); ok(true); start(); }); </code></pre> <p>This yields the console output (note that setup is called twice, then not again):</p> <pre><code>setup called test1 teardown called (2)setup called test3 teardown called test2 teardown called </code></pre> <p>Remove the start/stop, or modifying my test files to not be loaded programatically (i.e.: using traditional tags):</p> <pre><code>test('Test3', function() { console.log('test3'); ok(true); }); </code></pre> <p>Yields a more expected order of execution:</p> <pre><code>setup called test1 teardown called setup called test2 teardown called setup called test3 teardown called </code></pre> <p>Am I misunderstanding something about how this should be functioning?</p>
    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. 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