QUnit does not print any results

I have the most basic examples of a test runner page shown on a QUnit page inserted in an MVC project.

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>QUnit basic example</title> <link rel="stylesheet" href="../Content/qunit-1.11.0.css"> </head> <body> <div id="Div1"></div> <div id="Div2"></div> <script src="../Scripts/qunit-1.11.0.js"></script> <script> test("a basic test example", function () { var value = "hello"; equal(value, "hello", "We expect value to be hello"); }); </script> </body> </html> 

When I run this, I just see a blank page. Tests are performed when they stop at a breakpoint. Links to .css and .js are correct and working.

+4
source share
3 answers

I had the same problem with MVC, and I fixed it by getting the source files from qunit, instead of relying on nuget. After I did this, everything worked out fine.

+9
source

Two divs must have the following identifiers, because QUnit is looking for them to display something.

  <div id="qunit"></div> <div id="qunit-fixture"></div> 
+3
source

QUnit for ASP.Net MVC requires something else. Instead of the usual qunit and qunit-fixture divs, use something like this:

 <div> <h1 id="qunit-header">QUnit Test Results</h1> <ol id="qunit-tests"></ol> </div> 

For a complete example, see Unit Testing JavaScript / JQuery in ASP.Net MVC Project using QUnit Step by Step

+2
source

All Articles