我正在尝试在测试中注入 jQuery,但出现以下错误:
ReferenceError:找不到变量:$
这是我正在尝试测试的 ruby on rails 应用程序,在 WEBrick 上运行。这是所有代码:
var casper = require('casper').create({
clientScripts: ['jquery-1.9.1.min.js']
});
//make sure page loads
casper.start('http://127.0.0.1:3000', function() {
this.test.assertTitle('EZpub', 'EZpub not loaded');
});
//make sure all 3 fridges are displayed
casper.then(function() {
//get fridges
var fridges = $('a[href^="/fridges/"]');
this.test.assert(fridges.length == 3, 'More or less than 3 fridge links shown');
});
casper.run(function() {
this.echo('Tests complete');
});