【问题标题】:Jasmine test suite doesn't runJasmine 测试套件未运行
【发布时间】:2018-11-02 01:28:03
【问题描述】:

我不知道我做了什么让 Jasmine 搞砸了。

这是我正在处理的存储库的链接: https://github.com/bryanbeus/04-09-bloccit/tree/v0.1.3

问题与/spec/integration/flairs_spec.js/spec/integration/post_spec.js 等文件有关。

运行npm test 之类的命令时会出现问题。我得到以下结果:

04-09-bloccit@1.0.0 test /home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit
export NODE_ENV=test && jasmine
npm ERR! Test failed.  See above for more details.

过去,只有当我的代码中某处出现不可编译的错误时,才会发生此 ERR。 (例如,; 之类的简单事情不合适,或者 this 的使用不当。)

最近,我从其他人那里听说,Jasmine 的这种失败是不正常的。通常,如果代码有问题,Jasmine 还是应该说些什么。 ?

无论问题是什么,它现在都在普遍使用。

我正在尝试使用此命令调用server npm 模块进行测试:

const server = require("../../src/server");

如果该行在我的文件中的任何位置,则整个 Jasmine 测试都会以完全相同的方式失败。 (npm ERR... 没有其他细节。)

如果我在调用server 的情况下运行npm test /spec/integration/flairs_spec.js,则测试以npm ERR... 的方式失败。

但是,如果我注释掉对server 的调用,那么 Jasmine 至少会运行。它返回此错误:

........

开始 F

失败: 1)路线:flairs GET /topics/:topicId/posts/:postId/flairs/new 应该呈现一个新的flair表单 信息: 预期错误:将 ECONNREFUSED 127.0.0.1:3000 连接为空。 堆: 错误:预期错误:将 ECONNREFUSED 127.0.0.1:3000 连接为空。 在 在 Request.request.get [as _callback] (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/spec/integration/flairs_spec.js:57:21) 在 self.callback (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:186:22) 在 Request.emit (events.js:160:13) 在 Request.onRequestError (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:878:8) 在 ClientRequest.emit (events.js:160:13) 在 Socket.socketErrorListener (_http_client.js:389:9) 在 Socket.emit (events.js:160:13) 在 emitErrorNT (internal/streams/destroy.js:64:8) 在 process._tickCallback (internal/process/next_tick.js:152:19) 信息: 预期未定义包含“新天赋”。 堆: 错误:预期未定义包含“新天赋”。 在 在 Request.request.get [as _callback] (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/spec/integration/flairs_spec.js:58:22) 在 self.callback (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:186:22) 在 Request.emit (events.js:160:13) 在 Request.onRequestError (/home/siddhartha/Documents/07-Temp/01-Bloc/04-09-bloccit/node_modules/request/request.js:878:8) 在 ClientRequest.emit (events.js:160:13) 在 Socket.socketErrorListener (_http_client.js:389:9) 在 Socket.emit (events.js:160:13) 在 emitErrorNT (internal/streams/destroy.js:64:8) 在 process._tickCallback (internal/process/next_tick.js:152:19)

1 个规范,1 个失败 在 0.399 秒内完成 npm 错误!测试失败。有关详细信息,请参见上文。

.......

因此,删除 server 调用至少可以让 Jasmine 运行。

对此的任何帮助表示赞赏。感谢您帮助新手程序员。

【问题讨论】:

    标签: node.js npm jasmine


    【解决方案1】:

    我找到了错误的根源。

    使用git diff v0.1.2..v0.1.3 我能够看到最后一个工作分支和当前分支之间的差异。

    从这里,我看到在 db/src/controllers/flairController.js 中,我已将其放置在 fair 对象的控制器中:

    const flairQueries = require("./db/queries.flairs.js");
    

    问题在于目录不正确。我用这个替换它:

    const flairQueries = require("../db/queries.flairs.js");
    

    在此之后,Jasmine 测试套件开始工作。

    我了解这意味着控制器无法正确加载。对此的完全理解仍然难以捉摸,所以如果有人有时间尝试解释,我将不胜感激。否则,我们可以认为这个问题已经结束。谢谢!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-15
      • 1970-01-01
      • 1970-01-01
      • 2011-10-15
      • 2016-06-13
      • 1970-01-01
      • 1970-01-01
      • 2013-05-29
      相关资源
      最近更新 更多