2016-12-20 5 views
0

wenn ich laufe eine Datei in CMD js Probe. Es zeigt Fehler wie Fehler: Kann Test Framework "Mocha" nicht finden. Bitte helfen Sie mir, dieses Problem zu lösen.Erste Mokka Fehler in Eingabeaufforderung

Fehler nach dem Ausführen von Tests:

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") 
     ^^^^^^^ 
SyntaxError: missing) after argument list 
at exports.runInThisContext (vm.js:53:16) 
at Module._compile (module.js:373:25) 
at Object.Module._extensions..js (module.js:416:10) 
at Module.load (module.js:343:32) 
at Function.Module._load (module.js:300:12) 
at Function.Module.runMain (module.js:441:10) 
at startup (node.js:139:18) 
at node.js:968:3 

Package.json:

{ 
    "name": "macaca-test-sample", 
    "version": "0.1.0", 
    "description": "macaca-test-sample", 
    "keywords": [ 
     "sample" 
    ], 
    "main": "index.js", 
    "repository": { 
     "type": "git", 
     "url": "git://github.com/xudafeng/macaca-test-sample.git" 
    }, 
    "dependencies": { 
     "mocha": "^3.2.0" 
    }, 
    "devDependencies": { 
     "jshint": "*", 
     "mocha": "^3.2.0", 
     "pre-commit": "1.1.1", 
     "webdriver-client": "~1.0.0" 
    }, 
    "scripts": { 
     "test": "mocha", 
     "jshint": "make jshint" 
    }, 
    "pre-commit": [ 
     "jshint" 
    ], 
    "homepage": "github.com/xudafeng/macaca-test-sample";, 
    "author": "xudafeng", 
    "email": "[email protected]", 
    "blog": "xdf.me";, 
    "license": "MIT" 
} 
+0

Share-Code bitte. –

+0

installieren Mokka 'globally' – Shaharyar

+0

Shaharyar, wie kann ich das –

Antwort

0

Dies ist die Ausgabe von istanbul an Fenstern und Sie haben diese npm als Abhängigkeit in macacajs:

erklärt here als:

Istanbul assumes that the command passed to it is a JS file (e.g. Jasmine, vows etc.), this is however not true on Windows where npm wrap bin files in a .cmd file. Since Istanbul can not parse .cmd files you need to reference the bin file manually.

Here is an example using Jasmine 2:

istanbul cover node_modules\jasmine\bin\jasmine.js 

In order to use this cross platform (e.i. Linux, Mac and Windows), you can insert the above line into the script object in your package.json file but with normal slash.

"scripts": { 
    "test": "istanbul cover node_modules/jasmine/bin/jasmine.js" 
} 

So ist die einfache Lösung ist das obige Snippet in Ihre package.json hinzuzufügen.

+0

Immer noch das Problem –