测试茉莉花返回未定义的响应

时间:2019-06-29 16:53:09

标签: node.js testing jasmine

我编写了一个节点JS应用程序,并在其中传递了mongoDB url。通过process.env,我能够将mongoDB网址解析为我的js。原因是我不希望对mongoDB ip进行硬编码。它应该能够随时替换为在单独的基础架构环境中托管的另一个mongoDB数据库。即MONGODB_URL='mongodb://localhost:27017/user' npm test npm start

我正在使用茉莉花节点为此编写一个测试用例,但是,当我尝试执行var request = require("request"); var base_url = "http://localhost:4000/"; var server = require("../app.js"); // sample unit test begin describe("Test Base Page", function() { describe("GET /", function() { it("returns status code 200", function(done) { request.get("http://localhost:4000/", function(error, response, body) { console.log("example") console.log(response) expect(response.statusCode).toBe(200); done(); server.close() }); }); }); }); 时,似乎没有任何测试用例正在运行,并且它为我的响应返回了未定义的内容。

这是我在开发分支中的代码https://github.com/leeadh/node-jenkins-app-example的github存储库。

有人知道原因是什么或者我应该怎么写?

谢谢

{{1}}

0 个答案:

没有答案