我似乎在使用CasperJS为基于ExpressJS的Web应用程序创建功能测试套件时遇到了一个非常基本的问题。我似乎无法连接到以下内容:
我创建了一个简单的Express应用程序来使用Express可执行文件进行测试,例如:
以下是测试脚本,我想要做的就是连接到我的Express页面并检查标题,该标题应为“Express”。
这里发生了什么?
我创建了一个简单的Express应用程序来使用Express可执行文件进行测试,例如:
express myapp
。 我使用node app.js
启动该应用程序。以下是测试脚本,我想要做的就是连接到我的Express页面并检查标题,该标题应为“Express”。
var casper = require("casper").create({
logLevel: "debug"
});
casper.start("localhost:3000/")
casper.then(function() {
this.test.assertTitle("Express", "Express homepage title is the one expected");
});
casper.run(function() {
this.exit();
});
当我尝试连接到上述的 localhost
时,会收到以下错误消息。看起来 Casper 找不到标题。
FAIL Express homepage title is the one expected
# type: assertTitle
# subject: ""
# expected: "Express"
如果我试图连接到我的服务器的外部域名,例如casper.start("http://mydomain.com:3000/")
,那么测试通过。
PASS Express homepage title is the one expected
这里发生了什么?