简体   繁体   中英

jasmine-node failing a passing test, with npm error code ELIFECYCLE

Short story, running my jasmine-node tests fails an assertion of equality on identical arrays, then gives a NPM error ELIFECYCLE.

This is occurring on a couple of tests, but at the moment I've only got one running.

Here's the module; https://github.com/Thomas-Elder/hobby.node.happening/blob/mgmt/server/mgmt.js

Here's the spec; https://github.com/Thomas-Elder/hobby.node.happening/blob/mgmt/spec/server/mgmt_spec.js

The only test being run at the moment is the first one in the mgmt_spec.js file.

Here's the npm-debug.log for the test run;

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 ]

The spec runs, and then advises that an assertion has failed, but the message is:

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' } ].

Which shouldn't fail… they're equal arrays, right?

Following the failure message, there's the NPM error, details of which are repeated in the npm-debug.log.

Any clue what's happening here?

Ok so I sorted this somewhat. The issue I was having was unrelated to the NPM error I was seeing. The reason the spec was failing was because I was comparing object literals, to objects created using a constructor.

This became apparent when I finally updated my spec runner to Jasmine (from jasmine-node). Jasmine's logging output was;

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' }) ]

This had me looking at how I'd set up the spec, and after amending the spec (see repo link above), it passed.

The ELIFECYCLE error just seems to happen any time a spec fails.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM