2016-12-20 7 views
0

エラーのようなエラーが表示されます:テストフレームワーク "mocha"が見つかりません。この問題を解決するのを手伝ってください。テストの実行後CMDでサンプルjsファイルを実行すると、コマンドプロンプトでmochaエラーが発生する

エラー:

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

シェアコードをお願いします。 –

+0

mocha 'globalally'をインストールする – Shaharyar

+0

Shaharyar、どうすればいいですか? –

答えて

0

これは、Windows上のistanbulの問題であり、あなたはmacacajsに依存関係としてこのNPMがあります

説明しましたhere

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" 
} 

だから、簡単な解決策は、あなたのpackage.jsonに上記のスニペットを追加することです。

+0

問題が引き続き発生しています –

関連する問題