I'm trying to use chai spies with mocha running on browser, but something is not working.
With this html configuration:
<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>
And this test file:
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();
});
});
I get the following assertion error:
AssertionError: expected { Spy } to have been called
at Context.<anonymous> (test/input-text-test-fixture.html:282:28)
Someone can tell me what I'm doing wrong?
Aucun commentaire:
Enregistrer un commentaire