Qunit: ReferenceError: equals is not defined
Qunit: ReferenceError: equals is not defined
我是 QUnit 新手。
我创建了简单测试,但它失败并出现错误:"ReferenceError: equals is not defined"。我的代码如下:
simpleTests.js:
QUnit.test('isEven()', function (assert) {
equals(2, 1, 'one equals one');
})
simpleTestRun.js:
<html>
<head>
<title>QUnit Test Suite</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="qunit/qunit.js"></script>
<!-- Your JS library file goes here -->
<script type="text/javascript" src="simple.js"></script>
<!-- Your tests file goes here -->
<script type="text/javascript" src="simpleTests.js"></script>
</head>
<body>
<h1 id="qunit-header">QUnit Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</body>
</html>
怎么了?
更新 1:
我在本地磁盘上进行 QUnit 测试,而不是通过网络服务器。它如何影响测试?
equal
(不是equals
)是assert的一个方法,所以要这样使用:
QUnit.test('isEven()', function (assert) {
assert.equal(2, 1, 'one equals one');
})
我是 QUnit 新手。
我创建了简单测试,但它失败并出现错误:"ReferenceError: equals is not defined"。我的代码如下:
simpleTests.js:
QUnit.test('isEven()', function (assert) {
equals(2, 1, 'one equals one');
})
simpleTestRun.js:
<html>
<head>
<title>QUnit Test Suite</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="qunit/qunit.js"></script>
<!-- Your JS library file goes here -->
<script type="text/javascript" src="simple.js"></script>
<!-- Your tests file goes here -->
<script type="text/javascript" src="simpleTests.js"></script>
</head>
<body>
<h1 id="qunit-header">QUnit Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</body>
</html>
怎么了?
更新 1: 我在本地磁盘上进行 QUnit 测试,而不是通过网络服务器。它如何影响测试?
equal
(不是equals
)是assert的一个方法,所以要这样使用:
QUnit.test('isEven()', function (assert) {
assert.equal(2, 1, 'one equals one');
})