0
私はブラウザ上で実行中のmochaでチャイのスパイを使用しようとしていますが、何かが動作していません。ブラウザでチャイのスパイが動作しない
<html>
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link rel="stylesheet" href="./node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="./node_modules/mocha/mocha.js"></script>
<script src="./node_modules/chai/chai.js"></script>
<script src="./node_modules/chai-spies/chai-spies.js"></script>
<script>
mocha.setup('bdd')
mocha.reporter('html');
var expect = chai.expect;
</script>
<script src="./test.js"></script>
<script>
if (navigator.userAgent.indexOf('PhantomJS') < 0) {
mocha.run();
}
</script>
</body>
</html>
そして、このテストファイル:このHTML構成で
describe("test spies", function() {
it("are worning", function() {
function myFunction() {
console.log("Hello");
}
var spy = chai.spy(myFunction);
expect(spy).to.be.spy;
myFunction();
expect(spy).to.have.been.called();
});
});
私は、次のアサーションエラーを取得:
AssertionError: expected { Spy } to have been called
at Context.<anonymous> (test/input-text-test-fixture.html:282:28)
誰かが私は何を私に伝えることができます間違っている?
どのブラウザをお使いですか? –
私はクロムに取り組んでいます – Marchinka
奇妙な、テストコードはOKであるようです。 –