【问题标题】:jasmine-node failing a passing test, with npm error code ELIFECYCLEjasmine-node 未通过测试,npm 错误代码为 ELIFECYCLE
【发布时间】:2017-08-15 19:02:25
【问题描述】:

简而言之,运行我的 jasmine-node 测试无法在相同数组上断言相等,然后给出 NPM 错误 ELIFECYCLE。

这发生在几个测试中,但目前我只运行了一个。

这是模块; https://github.com/Thomas-Elder/hobby.node.happening/blob/mgmt/server/mgmt.js

这是规格; https://github.com/Thomas-Elder/hobby.node.happening/blob/mgmt/spec/server/mgmt_spec.js

目前唯一正在运行的测试是 mgmt_spec.js 文件中的第一个测试。

这是用于测试运行的 npm-debug.log;

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files (x86)\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'test' ]
2 info using npm@2.14.12
3 info using node@v4.2.4
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info pretest happening@0.0.1
6 info test happening@0.0.1
7 verbose unsafe-perm in lifecycle true
8 info happening@0.0.1 Failed to exec test script
9 verbose stack Error: happening@0.0.1 test: `jasmine-node --verbose --captureExceptions --forceexit ./spec`
9 verbose stack Exit status 1
9 verbose stack     at EventEmitter.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\lifecycle.js:214:16)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at EventEmitter.emit (events.js:172:7)
9 verbose stack     at ChildProcess.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at ChildProcess.emit (events.js:172:7)
9 verbose stack     at maybeClose (internal/child_process.js:818:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
10 verbose pkgid happening@0.0.1
11 verbose cwd E:\js\apps\happening
12 error Windows_NT 10.0.14393
13 error argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
14 error node v4.2.4
15 error npm  v2.14.12
16 error code ELIFECYCLE
17 error happening@0.0.1 test: `jasmine-node --verbose --captureExceptions --forceexit ./spec`
17 error Exit status 1
18 error Failed at the happening@0.0.1 test script 'jasmine-node --verbose --captureExceptions --forceexit ./spec'.
18 error This is most likely a problem with the happening package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     jasmine-node --verbose --captureExceptions --forceexit ./spec
18 error You can get their info via:
18 error     npm owner ls happening
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

规范运行,然后建议断言失败,但消息是:

Expected 
[ { id : '123', name : 'Tom' }, 
  { id : '456', name : 'Tim' }, 
  { id : '789', name : 'Tum' } ] 

to equal 
[ { id : '123', name : 'Tom' }, 
  { id : '456', name : 'Tim' }, 
  { id : '789', name : 'Tum' } ].

哪个不应该失败……它们是相等的数组,对吧?

在失败消息之后,出现 NPM 错误,其详细信息在 npm-debug.log 中重复。

知道这里发生了什么吗?

【问题讨论】:

    标签: javascript node.js jasmine-node


    【解决方案1】:

    好的,所以我对此进行了一些排序。我遇到的问题与我看到的 NPM 错误无关。规范失败的原因是因为我将对象文字与使用构造函数创建的对象进行比较。

    当我最终将我的规范运行器更新为 Jasmine(来自 jasmine-node)时,这一点变得很明显。 Jasmine 的日志输出是;

    Expected 
    [ ({ id: '123', name: 'Tom' }), ({ id: '456', name: 'Tim' }), ({ id:'789', name: 'Tum' }) ] 
    to equal 
    [ Object({ id: '123', name: 'Tom' }), Object({ id: '456', name: 'Tim' }), Object({ id: '789', name: 'Tum' }) ]
    

    这让我查看了我是如何设置规范的,在修改规范后(参见上面的 repo 链接),它通过了。

    ELIFECYCLE 错误似乎只是在规范失败的任何时候发生。

    【讨论】:

      猜你喜欢
      • 2020-02-12
      • 2021-12-03
      • 1970-01-01
      • 2014-06-10
      • 2020-10-23
      • 1970-01-01
      • 2017-11-15
      • 2021-01-18
      相关资源
      最近更新 更多