工具
sample_zombie_spec.js
var Browser, assert, browser, url, title;
assert = require('assert');
Browser = require('zombie');
var google = "https://google.com"
var google_title = "Google"
url = google
title = google_title
browser = new Browser();
describe('home page', function() {
describe('title', function() {
it('should have a title', function(done) {
browser.visit(url).then(function() {
assert.equal(browser.text('title'), title);
done();
}).fail(function(err) {
console.log('Failed with error: ', error);
done(err);
});
});
});
});
此文件位于spec/
中,因此我运行了以下命令:
jasmine-node spec/
结果:
F
Failures:
1) home page title should have a title
Message:
TypeError: Object [object Promise] has no method 'fail'
Stacktrace:
TypeError: Object [object Promise] has no method 'fail'
at null.<anonymous> (/home/dmmmd/Dropbox/node_js_projects/affinity-zombie/spec/sample_zombie_spec.js:21:12)
at null.<anonymous> (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/async-callback.js:45:37)
at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
Finished in 0.12 seconds
1 test, 1 assertion, 1 failure, 0 skipped
我在另一台机器上尝试了完全相同的事情:
结果:
F
Failures:
1) home page title should have a title
Message:
TypeError: undefined is not a function
Stacktrace:
TypeError: undefined is not a function
at null.<anonymous> (/Users/dmmmd/Dropbox/node_js_projects/spec/sample_zombie_spec.js:21:12)
at null.<anonymous> (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/async-callback.js:45:37)
at Timer.listOnTimeout (timers.js:89:15)
Finished in 0.069 seconds
1 test, 1 assertion, 1 failure, 0 skipped
我也尝试了其他一些网址,即使是本地网站也没有成功。
JavaScript,node.js,io.js,zombie和jasmine对我来说都是新手,所以我基本上只是从文档和stackoverflow问题中了解食谱。我将不胜感激任何建议。我怀疑我错过了一些非常简单的事情。
感谢。