Rsh7822
Rsh7822

Reputation: 41

Uncaught ReferenceError: require is not defined in QUnit test

I am trying to test simple example with qUnit. it shows me error

Uncaught ReferenceError: require is not defined in test.js file.

I am using express server in javascript but not using jQuery.

qunit.html

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

test/test.js

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

Upvotes: 4

Views: 1110

Answers (1)

Vipul Dessai
Vipul Dessai

Reputation: 320

wrap the Qunit.test inside a Qunit.module

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

Upvotes: 1

Related Questions