在实习生testing中包含jQuery

我如何testing自定义的JavaScript应用程序(包括jQuery作为依赖)? 我已经试过jQuery的Node包没有成功…

我是否需要在testing套件依赖项中以某种方式定义它? 我试过这个:

define([ 'intern!bdd', 'intern/chai!expect', 'node-jquery' ], ... 

你在正确的轨道上。 如果你想加载和testing任意的JavaScript,你只需要这样做:

 define([ 'intern!bdd', 'intern/chai!expect', 'libs/jquery.js', 'app/foo.js', 'app/bar.js' ], function (bdd, expect) { bdd.describe('my test', function () { bdd.it('should find foos on the page', function () { expect(jQuery('.foo')).to.have.length.of.at.least(2); }); }); // access other global variables here });