Blanket.js报告未显示Mocha.js的报告

时间:2014-11-21 16:14:51

标签: javascript mocha blanket.js

在使用mocha.js进行测试时,我无法在浏览器中显示Blanket.js报告。我的HTML文件是:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Cow tests</title>
  <link rel="stylesheet" media="all" href="vendor/mocha.css">
</head>
<body>
  <div id="mocha"><p><a href=".">Index</a></p></div>
  <div id="messages"></div>
  <div id="fixtures"></div>
  <script src="vendor/mocha.js"></script>
  <script src="vendor/chai.js"></script>
  <script src="vendor/blanket.min.js" data-cover-adapter="vendor/mocha-blanket.js"></script>
  <script>mocha.setup('bdd')</script>
  <script src="cow.js" data-cover></script>
  <script src="cow_test.js"></script>
  <script>mocha.run();</script>
</body>
</html>

我的cow.js文件是:

// cow.js
(function (exports) {
    "use strict";

    function Cow(name) {
        this.name = name || "Anon cow";
    }
    exports.Cow = Cow;

    Cow.prototype = {
        greets: function (target) {
            if (!target)
                throw new Error("missing target");
            return this.name + " greets " + target;
        }
    };
})(this);

我的cow_test.js文件是:

var expect = chai.expect;

describe("Cow", function () {
    describe("constructor", function () {
        it("should have a default name", function () {
            var cow = new Cow();
            expect(cow.name).to.equal("Anon cow");
        });

        it("should set cow's name if provided", function () {
            var cow = new Cow("Kate");
            expect(cow.name).to.equal("Kate");
        });
    });

    describe("#greets", function () {
        it("should greet passed target", function () {
            var greetings = (new Cow("Kate")).greets("Baby");
            expect(greetings).to.equal("Kate greets Baby");
        });
    });
});

当我打开html文件时,我得到的是mocha结果。我已多次检查我的依赖项是否在正确的位置,而blanket.min.js文件与mocha-blanket.js文件位于同一文件夹中,该文件与mocha.js位于同一目录中。

0 个答案:

没有答案