Select list for QUnit modules in test runner bar?
Asked Answered
C

1

6

I recall having seen at some point screen shots of a select list of QUnit test modules in the test runner toolbar of QUnit. My impression was that selecting one of the modules in the select list would cause that module's tests to be run.

Question: Does such a feature actually exist OOB for QUnit? I know one can set filter via the URL but I would like a more "discoverable" option.

Thanks!

Consociate answered 25/12, 2012 at 5:52 Comment(0)
P
9

The select list only shows itself if you have defined more than one module in your test suite.

Also, make sure that your test suite is ready before QUnit initializes itself. i.e. QUnit initializes itself when the page finishes loading (the onload event). If you happen to define your test suite after this, then you have to call the (undocumented) QUnit.load() method to notify QUnit that your test suite has been defined.

Demo: http://jsfiddle.net/brianpeiris/98fc8/show/

Phaih answered 25/12, 2012 at 6:17 Comment(4)
I am dynamically loading QUnit and my tests. Calling QUnit.load after QUnit is dynamically loaded makes the module picker show up.Consociate
Ultimately we found that calling QUnit.load was causing setup and teardown to run out of order (e.g., setup/setup/test/test/teardown/teardown). This is due to the fact that we are also async loading QUnit. We changed our boot strapping logic to be like the following and we now get the correct setup/test/teardown calling pattern: 1) Async load QUnit. 2) Set autostart to false. 3) Call QUnit.load 4) Async load test assets (i.e., js files containing tests) 5) Call QUnit.startConsociate
Thanks for the update. I guess there was a reason that the method was undocumented after all!Phaih
Here is the relevant bug report on GitHub suggesting the use of QUnit.load(): github.com/jquery/qunit/issues/396Waynant

© 2022 - 2024 — McMap. All rights reserved.