我正试图用mocha-phantomjs开始,我似乎遇到了关于要求的问题。我希望其他一双眼睛能看出我做错了什么。
$ mocha-phantomjs test/index.html
My Site
1) server should be running
Error: Script error for: webpage
http://requirejs.org/docs/errors.html#scripterror
相关文件相当小:
https://gist.github.com/cobaltroad/6675855
这是特别是spec脚本:
test.spec.js
describe("My Site", function() {
it("server should be running", function(done) {
require(['webpage'], function(webpage) {
var page = webpage.create();
page.open("http://localhost:8080/", function() {
var title = page.evaluate(function () {
return document.title;
});
title.should.eql('My Title');
console.log("Title: " + title);
phantom.exit();
done();
});
});
}); // server should be running
});
我尝试了各种形式的define / require,但我还是没能做到这一点。