I've got my app properly configured, such that if I run node app.js
everything starts up. I'm trying to test for the connection of my app is working properly using unit tests. What I have so far is:
var options = {
url: 'http://localhost',
port: 8080,
};
var app = require("../app.js");
var should = require('should');
var assert = require("assert");
var async = require('async');
it ('tests the ok connection of the app by checking that it is listening on port 8080', function(dont) {
request(options,app)
.get('/')
.expect(200)
.end(function (err, res) {
res.header['location'].should.include('/')
res.text.should.include('Listening on port 8080');
done();
});
});
I was getting the error message Error: options.uri is a required argument
, which is why I added the var options
. Now I'm getting error message TypeError: Object #<Request> has no method 'get'
.
How can properly check that I have a good connection ( 200
), that i'm on the right page ( '/'
) and that it is logging the message Listening on port 8080
upon connection?
Thanks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.