2014-04-25 12 views
10

मैं यूनिट परीक्षण के लिए मोचा-फ़ैंटोमज सेटअप का उपयोग कर रहा हूं। मेरे पास परीक्षण चलाने के लिए निम्नलिखित पैकेज.जेसन लेखक हैं।एनपीएम त्रुटि ELIFECYCLE परीक्षण चलाते समय

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

यह रन ब्राउज़र में ठीक है। और जब मैं cmd ​​में आदेश npm test चलाने के लिए, परीक्षण ठीक चलाने लेकिन यह भी निम्नलिखित त्रुटि देता है

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 

कृपया किसी को भी मुझे बता सकते हैं कि कैसे मैं इस त्रुटि को हल कर सकते हैं।

उत्तर

3

और जब मैं cmd ​​में आदेश NPM परीक्षण, परीक्षण रन ठीक

नहीं वे नहीं हैं चलाते हैं। आपके पास 6 असफल परीक्षण हैं। का निकास कोड असफल परीक्षणों की संख्या के बराबर है। सीधे mocha-phantomjs ./test/FlickrTest.html चलाएं और देखें कि क्या असफल रहा है। PhantomJS को समझें अपने ब्राउज़र से थोड़ा अलग है - आप have to debug it कर सकते हैं।

आपकी स्क्रिप्ट सेटअप विषम है। आपको बस होना चाहिए:

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

तब विषम नोड त्रुटियों को दूर जाना चाहिए।

+0

लेकिन मैं उन्हें गलत आदानों पर विफल करना चाहते हैं। –

7

npm test चलाते समय यह ELIFECYCLE त्रुटियों को चलाता है ताकि आप कभी भी इस अनुभव का सामना न करें।

Reference to code

एक बार जब आप एक अलग पटकथा नाम करने के लिए एक परीक्षण स्क्रिप्ट को स्थानांतरित आप ELIFECYCLE त्रुटि मिल रही शुरू करेंगे।

मेरा फ़िक्स आदेश के अंत में exit 0 जोड़ने के लिए है। अपने कोड के लिए यह इस प्रकार दिखाई देगा:

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

मुझे इस समस्या का सामना करना पड़ा क्योंकि मैं अपने 'package.json' फ़ाइल में एकाधिक परीक्षण स्क्रिप्ट चाहता था। – Sgnl

+1

मनमानी स्क्रिप्ट के अंत में 'निकास 0' जोड़ना त्रुटियों को दबा देगा। – joemaller

+0

@joemaller विंडोज़ में नहीं है यह नहीं करता है। –

1

यह एक समस्या है जब npm run का उपयोग कर, यह मोचा कोड == 0 से बाहर निकलने के लिए जब भी एक परीक्षण में विफल रहता है के साथ क्या करना है। आप Windows पर हैं, तो यह प्रयास करें:

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

मैं इस एक ही समस्या हो रही थी, और मेरे लिए यह क्या तय था जब मैं अपने इकाई परीक्षण चलाने के लिए, नहीं उपयोग कर

npm run test 

बजाय का उपयोग करें:

npm test 
संबंधित मुद्दे