mocha + webstorm - error message broken

前端 未结 3 1480
离开以前
离开以前 2021-01-16 13:17

I try to use mocha with webstorm test runner on win 7.

I have these config params:

  • path to node:

    C:\\Program Files (x86)\\nodejs\\no         
    
    
            
相关标签:
3条回答
  • 2021-01-16 13:36

    While the greater powers are debating on the hows and the whys to fix this, lesser mortals can resort to this workaround:

    • Create a file called testRunner.js (or whatever)
    • add the following lines of code to it
    • modify the list of test files per your project
    • in webstorm, run the testRunner.js to run your tests

    testRunner.js

    var testFiles=["test/_helper.js","test/tests.js","test/tests.coffee"];
    
    var Mocha = require('mocha');
    
    var mocha = new Mocha;
    
    mocha.reporter('spec').ui('bdd');
    
    for (var i =0;i<testFiles.length;i++){
     mocha.addFile(testFiles[i]);
    }
    
    var runner = mocha.run(function(){
                    console.log('finished');
    
    });
    

    Courtesy: http://wuntusk.blogspot.com/2012/06/using-webstorm-or-phpstorm-and-mocha.html

    0 讨论(0)
  • 2021-01-16 13:49

    It's caused by a known Windows specific node issue, also logged in JetBrains issue tracker.

    0 讨论(0)
  • 2021-01-16 13:56

    Even after implementing Mrchief's answer, I am still getting scrambled reports in the output. I ended up running tests in the terminal window. As a reference;

    Make sure mocha is installed globally.

    npm install -g mocha
    

    Open the terminal window (Alt-Minus) and change to the directory where your test scripts are

    Run mocha

    mocha -R spec *.js

    0 讨论(0)
提交回复
热议问题