I seem to be having a very basic issue with using CasperJS to create a functional test suite for an ExpressJS based web application. I can't seem to connect to t
I created a barebones Express app to test using the Express executable, e.g. express myapp. I start the app with node app.js.
The below is the test script, what I want to do is simply connect to my Express page and check the title, which should be "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();
});
When I am trying to connect to localhost, as above, this is the error message I receive. It seems that casper can't find a title.
FAIL Express homepage title is the one expected
# type: assertTitle
# subject: ""
# expected: "Express"
If I change to trying to connect to my server's external domain, e.g. casper.start("http://mydomain.com:3000/"), then the test passes.
PASS Express homepage title is the one expected
What is going on here?
If you are sure that you are on port 3000 on localhost, I would try this:
casper.start("http://localhost:3000")