Tag: bdd

Sinon的假服务器没有响应

还有一些其他问题询问Sinon没有回应,但他们似乎都解决了一些平凡的问题,如无效的响应数据或切换配置选项。 我的情况如下: 在主应用程序(at /js/app/ )中,requireJS用于加载网站应用程序模块。 对于测试(at /js/test ),requireJS也用于加载相同的模块,但添加了Mocha , Chai和Sinon 。 这是test应用程序的引导程序: define( “testRunner”, [“require”, “chai”, “module”, “sinon”, “mocha”], function( require, chai, module ){ // Chai setup assert = chai.assert; should = chai.should(); expect = chai.expect; // Mocha setup mocha.setup( ‘bdd’ ); // tests require( module.config().tests, function(){ mocha.run(); } ); } ); require([“testRunner”]); module.config().tests在requirejs.config({})调用中定义为: “config”: […]

使用Sinon在D3中测试Mouseover事件

我在试图通过测试时遇到了麻烦。 我希望能够使用间谍来检查鼠标hover事件是否被正确调用。 目前我收到以下错误,“错误:预计至少被调用一次,但从未被调用过”。 我的部分困惑与d3和jQuery选择器之间的差异有关,我非常乐意使用后者,但我不确定如何在测试中正确使用前者来获得我想要的结果。 我的依赖是d3,jQuery,mocha,chai,sinon和sinon-chai。 我的index.html文件中的相关代码, mocha.ui(‘bdd’); mocha.reporter(‘html’); var expect = chai.expect; mocha.run(); fixtures.js, var path = svg.selectAll(“path”) .data(pie(data)) .enter().append(“path”).attr(“class”, “path”) .style(“fill”, function(d, i) { return color(i); }) .attr(“d”, arc) .on(“mouseover”, function() { d3.select(this).style(“fill”, “#ff0000”); }) .on(“mouseout” , function() { d3.selectAll(“path”).style(“fill”, function(d, i) { return color(i); }); }); // I wanted to test my understanding […]