Package: django-nose-qunit
Integrate QUnit JavaScript tests into a Django test suite via nose.Installationpip installdjango-nose-qunit.Add'django_nose_qunit'to yourINSTALLED_APPSsetting.Ensure that you’re using nose as your test runner by using the following
Django settingTEST_RUNNER = 'django_nose.NoseTestSuiteRunner'Enable the nose plugin by adding it to theNOSE_PLUGINSDjango setting:NOSE_PLUGINS = [
    'django_nose_qunit.QUnitPlugin'
]and theNOSE_ARGSDjango setting:NOSE_ARGS = [
    '--with-django-qunit',
]Add an entry to your URL configuration:from django_nose_qunit.urls import urlpatterns as qunit_urlpatterns
urlpatterns += qunit_urlpatternsThis adds new URLs of the form/qunit/*, and they return a 404
unlessDEBUGis True or QUnit tests have been initialized as part of a
test run.Configure Selenium as explained in thesbo-seleniumREADME.Make sureMEDIA_URLis set to some non-empty string, like “/media/”.
If this is not done, the live test server can occasionally get confused and
treat requests for a test page as requests for static files.Creating Unit TestsTests can be written in JavaScript using QUnit as normal; see theQUnit documentationfor details.  You need only create a
JavaScript file, not the HTML page that will load it (that is provided by the
template atqunit/template.html).  If your tests depend on HTML fixtures in the
qunit-fixture div, create those as HTML fragments in files which can be loaded
as templates.  External script dependencies should be files in the staticfiles
load path.  You should addQUnit.Django.start();before your test definitions
andQUnit.Django.end();at the end of your test definitions; this allows the
tests to start executing at an appropriate time depending on whether they’re
running in a browser, in a nose test run, or inside a require() block of an AMD
loader likeRequireJS.To make nose aware of your QUnit tests, create a subclass ofdjango_nose_qunit.QUnitTestCasein a file which would normally be searched by
nose, for examplemy_app/test/qunit/test_case.py.  It can contain as little as
just thetest_fileattribute (a path to a QUnit test script, relative toSTATIC_URL).  Any script dependencies for your test script should be given
as paths relative toSTATIC_URLin thedependenciesattribute.  Paths to
HTML fixture templates are listed in thehtml_fixturesattribute.Running Unit TestsUse your normal test execution command (using
django-admin.py or manage.py).  Execution can be restricted to one or more
specified packages and/or classes as normal (“myapp”, “myapp.tests.qunit”,
“myapp.tests.qunit:MyTestCase”, etc.).  There is currently no support for
running only a single module or test within a QUnit test script; QUnit module
and test names can be arbitrary strings, which makes it difficult for the nose
command line parser to handle them.To run the QUnit tests in a regular web browser, use the runserver management
command withQUNIT_DYNAMIC_REGISTRYset to True (by default, it has the same
value asDEBUG).  IfDEBUGis False, you’ll also need to use the--insecureparameter to serve static files.  You can then access a list of links to the
available QUnit tests at a URL likehttp://localhost:8000/qunit/.  This can be
useful when first developing a test script and when troubleshooting failing
tests.How It WorksQUnitTestCase is a subclass of Django’sLiveServerTestCase, which starts a
Django test server in the background on setup of the test class and stops it on
teardown.  django_nose_qunit includes a nose plugin which can accommodate tests
written as simple wrappers for JavaScript test files.  When nose searches for
tests to run, the plugin tells it how to ask a browser via Selenium WebDriver
to load each test script (without running the tests) in order to get
information about the modules and tests it contains.  Once these tests are
enumerated, they are run like any other test case.  The first execution of
a test from a QUnit test script runs all of the tests in the script, and the
results are stored.  Each test case then reports success or failure based on
the reported results, with failures including any messages provided by QUnit.