jonkemp / node-qunit-phantomjs

Run QUnit unit tests in a headless PhantomJS instance without using Grunt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Global vars, ReferenceError: Can't find variable: QUnit

estobbart opened this issue · comments

Using the QUnit Getting Started example I'm not able to run node-qunit-phantomjs.

test.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>QUnit Example</title>
  <link rel="stylesheet" href="//code.jquery.com/qunit/qunit-1.17.1.css">
</head>
<body>
  <div id="qunit"></div>
  <div id="qunit-fixture"></div>
  <script src="//code.jquery.com/qunit/qunit-1.17.1.js"></script>
  <script src="tests.js"></script>
</body>
</html>

test.js

QUnit.test( "hello test", function( assert ) {
  assert.ok( 1 == "1", "Passed!" );
});

Bash:

$ node-qunit-phantomjs ./testsuite/test.html 
Testing ../../testsuite/test.html
ReferenceError: Can't find variable: QUnit

file:///Users/Developer/testsuite/tests.js:1
ReferenceError: Can't find variable: QUnit

phantomjs://webpage.evaluate():6
The `QUnit` object is not present on this page.
{ [Error: Command failed: ] killed: false, code: 1, signal: null }

Add a protocol to your external resources (e.g., src="http://code.jquery.com..."). You are loading from a file URL, so src="//..." doesn't work.