node app.js
을 실행하면 모든 항목이 시작되도록 응용 프로그램이 제대로 구성되어 있습니다. 내가 단위 테스트를 사용하여 응용 프로그램의 연결이 제대로 작동하는지 테스트하려고합니다. 내가 지금까지있는 것은 : 나는 내가 var options
을 추가 왜 오류 메시지 Error: options.uri is a required argument
을 얻고 있었다express, nodeJS 및 Mocha를 사용하여 응용 프로그램 연결을 테스트하는 방법
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();
});
});
. 이제 오류 메시지 TypeError: Object #<Request> has no method 'get'
이 표시됩니다.
올바른 연결 (200
), 올바른 페이지 ('/'
) 및 연결시 메시지 Listening on port 8080
로깅을 제대로 확인하는 방법은 무엇입니까?
감사합니다.
옵션없이 '요청 (app)'만 사용해야합니다. 또한'should '에는'.include'가 없으며'.containEql'을 사용해야합니다. –