2013-01-08 22 views
10

के साथ मोचा परीक्षण मैं अपने प्रोजेक्ट को मचान करने के लिए Yeoman का उपयोग कर रहा हूं। यह कई आसान चीजों के साथ आता है, जिसमें PhantomJS-आधारित परीक्षण धावक शामिल है।Yeoman और PhantomJS

मेरी समस्या यह है कि जब मेरे परीक्षण ब्राउज़र में सही ढंग से चलते हैं, तो वे सीएलआई में फैंटॉमजेएस के साथ चलाने की कोशिश करते समय समय निकालते हैं। जब मैं yeoman test करते हैं, मैं इस मिल

require(['map'], function (Map) { 
    describe('Choropleth Map Generator', function() { 
    describe('Configure the map', function() { 
     it("should enforce mandatory parameters in the configuration", function() { 
     var config = {title: 'test configuration'}; 
     var map = new Map(config); 
     (function() { 
      map.getConfig(); 
     }).should.throw(Error); 
     }); 
    }); 
    }); 
}); 

अब,:

<!doctype html> 
<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
    <title>Mocha Spec Runner</title> 
    <link rel="stylesheet" href="lib/mocha/mocha.css"> 
</head> 
<body> 
    <div id="mocha"></div> 
    <script src="lib/mocha/mocha.js"></script> 
    <!-- assertion framework --> 
    <script src="lib/chai.js"></script> 

    <!-- include source files here... --> 
    <script data-main="scripts/main" src="scripts/vendor/require.js"></script> 

    <script> 
    mocha.setup({ui: 'bdd', ignoreLeaks: true}); 
    expect = chai.expect; 
    should = chai.should(); 
    require(['../spec/map.spec'], function() { 
     setTimeout(function() { 
     require(['../runner/mocha']); 
     }, 100); 
    }); 
    </script> 

</body> 
</html> 

यहाँ map.spec.js है:

यहाँ कैसे अपने परीक्षण index.html लग रहा है की तरह है

Running "server:phantom" (server) task 

Starting static web server on port 3501 

[...] 

Running "mocha:all" (mocha) task 
Testing index.html 
<WARN> PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue. </WARN> 

Aborted due to warnings. 

जैसा कि मैंने कहा , yeoman server:test ब्रांड्स में मेरे दावे सही ढंग से दिखाता है owser।

मैं यमन 0.9.6 और फैंटॉमजेएस 1.7.0 का उपयोग कर रहा हूं। किसी भी मदद की सराहना की है।

उत्तर

3

Gruntfile में आपका मोचा कॉन्फ़िगरेशन क्या है।

mocha: { 
    all: ['http://localhost:3501/index.html'] 
}, 
+0

में mocha के लिए पथ दोबारा जांच से है कि एक ही चेतावनी हल यह डिफ़ॉल्ट, 'Yeoman init' द्वारा उत्पन्न है: आप की तरह कुछ है। वह है - 'मोचा: { सभी: ['test/**/*। Html'] },' –

+0

इससे यह मेरे लिए काम करता है, लेकिन पहली कोशिश से। यहां अधिक जानकारी - https://github.com/yeoman/yeoman/issues/719 –

+0

यहां एक कार्यरत टेम्पलेट है: https://github.com/roblevintennis/yeoman_requirejs_template – Rob

4

मैं test/index.html

<link rel="stylesheet" href="lib/mocha/mocha.css"> 
</head> 
<body> 
    <div id="mocha"></div> 
    <script src="lib/mocha/mocha.js"></script> 
+0

मेरे पास अभी भी HTML में संदर्भित 'mocha.js' है, यह मेरे लिए नहीं बदला है। मैं अपनी परियोजना के लिए रीढ़ की हड्डी का उपयोग नहीं करता हूं। –

+1

मेरे मामले में, मैंने माना कि जब मैं मूल वेबपैप जनरेटर चलाता हूं तो महिला मोचा स्थापित करेगी। मेरे सूचकांक पथ की जांच करने के बाद और जहां यह इंगित किया गया, मैंने देखा कि यह गायब था। 'बोवर इंस्टाल मोचा' ने मुझे तय किया। – austin

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