开发者

Qunit and JQuery 1.5.2

开发者 https://www.devze.com 2023-02-26 18:43 出处:网络
Following code works with JQuery 1.4.4. The result it prints is: Tests completed in 152 milliseconds. 1 tests of 1 passed, 0 failed.

Following code works with JQuery 1.4.4. The result it prints is:

Tests completed in 152 milliseconds. 1 tests of 1 passed, 0 failed.

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>

<script type="text/javascript">
    $(function () {
        test("verify results", function () {
            ok(true, "all pass");
        });
    });
</script>

If changed to use JQuery 1.5.2,

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.2.min.js" type="text/javascript"></script>

The result it prints is:

Tests completed in 2426 milliseconds. 33 tests of 34 passed, 1 failed.

Is it a bug in JQuery 1.5.2?

The full source is:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <div id="page">
        <div id="main">
            <div id="content">
                <h2>Test Results</h2>
                <div id="qunit-testrunner-toolbar"></div>
                <ol id="qunit-tests"></ol>
                <div id="qunit-fixture"></div>
            </div>

            <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.2.min.js" type="text/javascript"></script>
            <script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>
            <script type="text/javascript">
            $(function () {
                test("verify result after post", function () {
                    ok(true, "all pass");
                });
            });
            </script>

            <div id="footer"></div>
        </div>
    <开发者_开发百科/div>
</body>
</html>


There are two problems:

  • The qunit.js script assumes the id="qunit" atrribute/value pair exists
  • The qunit.css reference is missing

For future reference, use the official boilerplate as a starting point:

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

精彩评论

暂无评论...
验证码 换一张
取 消