Why Does PhantomJS Refuse to Run my QUnit tests with Grunt?

68 views Asked by At

I am having no luck getting PhantomJS/Grunt to run QUnit tests that run perfectly when run in a browser.

Gruntfile.js:

module.exports = function (grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        qunit: {
            hello: ['test/helloQUnit.html']
        }

    });

    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-qunit');
    grunt.loadNpmTasks('grunt-contrib-watch');        
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-md2html');

    grunt.registerTask('default', ['qunit']);
};

test .html:

<!DOCTYPE html>
<html>

<head>
    <title>Hello QUnit</title>
    <script type="text/javascript" src="vendor/qunit.js"></script>
    <link rel="stylesheet" href="vendor/qunit.css" type="text/css"/>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>

<body>

<div id="qunit"></div>

<div id="qunit-fixture"></div>

<script type="text/javascript" src="helloQUnit.js"></script>

<script type="text/javascript">
    document.addEventListener('DOMContentLoaded', function () {
        helloQUnitTests();
    });
</script>

</body>
</html>

test .js function helloQUnitTests() {

test( "Passing QUnit Test", 1, function() {
    var value = "hello";
    equal( value, "hello");
});

test( "Failing QUnit Test", 1, function() { var number = 5; equal( number, 7); });

}

The error: enter image description here

I have no idea how to debug this. Any thoughts? What have I missed here?

0

There are 0 answers