2014-04-25 15 views
10

Sto utilizzando l'installazione di mocha-phantomjs per il test dell'unità. Ho seguito package.json scriot per eseguire i test.Errore npm ELIFECYCLE durante l'esecuzione del test

"scripts": { 
"test": "npm run testFlickr", 
"testFlickr": "mocha-phantomjs ./test/FlickrTest.html" 
} 

Questo funziona nel browser. E quando ho eseguito il comando npm test nel cmd, il test gestito bene, ma dà anche seguente errore

3 passing (5s) 
6 failing 


npm ERR! [email protected] testFlickr: `mocha-phantomjs ./test/FlickrTest.html` 
npm ERR! Exit status 6 
npm ERR! 
npm ERR! Failed at the [email protected] testFlickr script. 
npm ERR! This is most likely a problem with the flickr-test package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  mocha-phantomjs ./test/FlickrTest.html 
npm ERR! You can get their info via: 
npm ERR!  npm owner ls flickr-test 
npm ERR! There is likely additional logging output above. 
npm ERR! System Windows_NT 6.1.7600 
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod 
ejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "testFlickr" 
npm ERR! cwd C:\Users\user\Desktop\test 
npm ERR! node -v v0.10.26 
npm ERR! npm -v 1.4.3 
npm ERR! code ELIFECYCLE 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  C:\Users\user\Desktop\test\npm-debug.log 
npm ERR! not ok code 0 
npm ERR! Test failed. See above for more details. 
npm ERR! not ok code 0 

favore qualcuno può dirmi come posso risolvere questo errore.

risposta

3

E quando ho eseguito il test di comando NPM nel cmd, la prova di funzionamento va bene

No non lo sono. Hai 6 test falliti. Il codice di uscita mocha-phantomjs è uguale al numero di test non riusciti. Esegui direttamente mocha-phantomjs ./test/FlickrTest.html e vedi cosa non funziona. Renditi conto che PhantomJS è leggermente diverso dal tuo browser: puoi have to debug it.

L'impostazione dello script è dispari. Devi solo avere:

"scripts": { 
    "test": "mocha-phantomjs ./test/FlickrTest.html" 
} 

Quindi gli errori di nodo dispari dovrebbero andare via.

+0

Ma voglio che vengano errati su input errati. –

7

Quando si esegue npm test si squelches gli errori ELIFECYCLE in modo da non incontrare mai questa esperienza.

Reference to code

volta che si sposta uno script di test a uno script-nome diverso si iniziano a vedere ELIFECYCLE errori.

La mia correzione è aggiungere un exit 0 alla fine del comando. Per il codice sarebbe simile a questa:

"scripts": { 
    "test": "npm run testFlickr", 
    "testFlickr": "mocha-phantomjs ./test/FlickrTest.html; exit 0" 
} 
+0

Ho riscontrato questo problema perché volevo avere più script di test nel mio file 'package.json'. – Sgnl

+1

L'aggiunta di '; exit 0' alla fine di script arbitrari eliminerà gli errori. – joemaller

+0

@joemaller non in Windows no. –

1

Questo è un problema quando si utilizza npm run, ha a che fare con la moka uscendo con il codice == 0 ogni volta che un test fallisce!. Se siete su Windows provare questo:

"scripts": { 
    "test": "npm run testFlickr || ECHO.", 
    "testFlickr": "mocha-phantomjs ./test/FlickrTest.html || ECHO." 
} 
0

ho avuto questo stesso problema, e ciò che ha risolto il tutto per me è stato quando ho eseguito il mio test di unità, fare NON uso

npm run test 

invece utilizzare:

npm test 
Problemi correlati