Reputation: 23
I've installed the 2 Chutzpah Visual Studio add-ins (using VS 2015), the Context Menu and Test Explorer extensions. I can right click the test.js file and it runs successfully. I can run the test from Test Explorer and the test runs successfully. The problem is when I right click the test.html file, I get the following errors.
Error: Error: Called start() while test already started running at start in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 2679) at startQUnit (line 12) at onPageLoaded (line 16) (line 18) While Running:C:\Users\byron\documents\visual studio 2015\Projects\WebApplication1\WebApplication1\Tests\codeSample\test.html ------ Test started: File: C:\Users\byron\documents\visual studio 2015\Projects\WebApplication1\WebApplication1\Tests\codeSample\test.html ------ Error: TypeError: undefined is not an object (evaluating 'QUnit.jsDump.multiline = false') at log in undefined (line 88) at runLoggingCallbacks in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1036) at logAssertion in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1701) at pushResult in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1672) at pushFailure in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1685) at run in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1430) in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1620) at advance in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1105) at begin in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 2796) in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 2756) While Running:C:\Users\byron\documents\visual studio 2015\Projects\WebApplication1\WebApplication1\Tests\codeSample\test.html Error: TypeError: undefined is not an object (evaluating 'QUnit.jsDump.multiline = false') at log in undefined (line 88) at runLoggingCallbacks in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1036) at logAssertion in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1701) at pushResult in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1672) at pushFailure in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1685) at pushFailure in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 1822) at onError in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 2560) at onerror in file:///C:/Users/byron/documents/visual%20studio%202015/Projects/WebApplication1/WebApplication1/Tests/Framework/qunit-2.3.2.js (line 3844) While Running:C:\Users\byron\documents\visual studio 2015\Projects\WebApplication1\WebApplication1\Tests\codeSample\test.html Error: Timeout occurred when executing test file While Running:C:\Users\byron\documents\visual studio 2015\Projects\WebApplication1\WebApplication1\Tests\codeSample\test.html ========== Total Tests: 0 passed, 0 failed, 0 total ==========
I have used the Chutzpah sample files for testing with the addition of a test to test JQuery is working, here are the files and Chutzpah.json file.
test.html
<html>
<head>
<link rel="stylesheet" href="../Framework/qunit-2.3.2.css" type="text/css" />
<script type="text/javascript" src="../Framework/jquery-3.1.1.js"></script>
<script type="text/javascript" src="../Framework/qunit-2.3.2.js"></script>
<script type="text/javascript" src="code.js"></script>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<h1 id="qunit-header">Unit Tests</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests">
</ol>
<div id="qunit-fixture">test markup, will be hidden</div>
</body>
</html>
test.js
/// <reference path="code.js"/>
QUnit.module("test");
$(document).ready(function() {
QUnit.test("will add 5 to number",
function() {
var res = mathLib.add5(10);
QUnit.assert.equal(res, 15, "should add 5");
});
QUnit.test("test jquery",
function() {
var result = $("#qunit-fixture");
QUnit.assert.ok(result.length > 0);
});
});
code.js
var mathLib = {
add5: function (a) {
return a + 5;
}
}
Chutzpah.json
{
"RootReferencePathMode": "SettingsFileDirectory",
"References": [
{ "Path": "Framework" }
]
}
My project folder structure:
Ultimately, I need to update 250 JS tests to run all of them from Visual Studio. Currently, all the tests only run in TeamCity via a script.
Upvotes: 0
Views: 529
Reputation: 17608
Hit the same problem after upgrading QUnit and Chutzpah to their currently latest versions (2.3.2 and 4.3.4 respectively).
After much trying ended up reverting to the combination that worked (QUnit 1.18.0 and Chutzpah 4.2.2), which fixed the issue.
Upvotes: 0
Reputation: 16762
Chutzpah works best when run directly on a JS file. While Chutzpah does work on HTML files depending on your setup you may need to do more work. In this example since your test is wrapped waiting for document ready my guess is QUnit is starting running before your test registers.
You should just let Chutzpah generate the HTML for you though since that would be less maintenance and more robust.
Upvotes: 1