2017-05-30 58 views
0

我使用實習生4.0(是的,我知道這是一個alpha版本,但我想在es6中重寫我的代碼和單元測試)。實習生4:無法執行測試套件

我安裝了npm包「intern 4.0.0-alpha.4」,我在es6中重寫了代碼,單元測試和套件。

但我無法運行測試。 我想從故宮腳本運行測試:我編輯我package.json文件,以獲得:

"scripts": { 
    "test": "node_modules/.bin/intern config=intern.json" 
} 

或與-CLI間:

"scripts": { 
    "test": "node_modules/.bin/intern" 
} 

我「M也試過

"scripts": { 
    "test": "intern run --config intern.json" 
} 

然後我運行命令npm run test

這裏日誌文件:

0 info it worked if it ends with ok 
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', 
1 verbose cli 'C:\\Users\\admin\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js', 
1 verbose cli 'run', 
1 verbose cli 'test' ] 
2 info using [email protected] 
3 info using [email protected] 
4 verbose run-script [ 'pretest', 'test', 'posttest' ] 
5 info lifecycle [email protected]~pretest: [email protected] 
6 silly lifecycle [email protected]~pretest: no script for pretest, continuing 
7 info lifecycle [email protected]~test: [email protected] 
8 verbose lifecycle [email protected]~test: unsafe-perm in lifecycle true 
9 verbose lifecycle [email protected]~test: PATH: ... 
10 verbose lifecycle [email protected]~test: CWD: D:\Temp\myproject 
11 silly lifecycle [email protected]~test: Args: [ '/d /s /c', 'intern config=intern.json' ] 
12 silly lifecycle [email protected]~test: Returned: code: 1 signal: null 
13 info lifecycle [email protected]~test: Failed to exec test script 
14 verbose stack Error: [email protected] test: `intern config=intern.json` 
14 verbose stack Exit status 1 
14 verbose stack  at EventEmitter.<anonymous> (C:\Users\admin\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:279:16) 
14 verbose stack  at emitTwo (events.js:106:13) 
14 verbose stack  at EventEmitter.emit (events.js:191:7) 
14 verbose stack  at ChildProcess.<anonymous> (C:\Users\admin\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14) 
14 verbose stack  at emitTwo (events.js:106:13) 
14 verbose stack  at ChildProcess.emit (events.js:191:7) 
14 verbose stack  at maybeClose (internal/child_process.js:886:16) 
14 verbose stack  at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) 
15 verbose pkgid [email protected] 
16 verbose cwd D:\Temp\myproject 
17 verbose Windows_NT 10.0.14393 
18 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\admin\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "test" 
19 verbose node v6.10.3 
20 verbose npm v4.4.4 
21 error code ELIFECYCLE 
22 error errno 1 
23 error [email protected] test: `intern config=intern.json` 
23 error Exit status 1 
24 error Failed at the [email protected] test script 'intern config=intern.json'. 
24 error Make sure you have the latest version of node.js and npm installed. 
24 error If you do, this is most likely a problem with the myproject package, 
24 error not with npm itself. 
24 error Tell the author that this fails on your system: 
24 error  intern config=intern.json 
24 error You can get information on how to open an issue for this project with: 
24 error  npm bugs myproject 
24 error Or if that isn't available, you can get their info via: 
24 error  npm owner ls myproject 
24 error There is likely additional logging output above. 
25 verbose exit [ 1, true ] 

你有什麼想法嗎?

回答

1

您可以使用

"scripts": { 
    "test": "intern" 
} 

因爲internnode_modules/.bin倉腳本,你不需要在package.json使用node_modules/.bin

只是爲了驗證,你可以嘗試運行

node node_modules\.bin\intern 

實習生應該運行您在intern.json配置的套房。

+0

是的,我用這個'4.0.0-alpha.5'。但'npm run test'失敗,'Feature'對象賦值'存在並覆蓋不成立'。我嘗試了沒有測試套件,我有同樣的錯誤。我不明白爲什麼! – Troopers

+0

這聽起來更像是加載測試運行程序的問題,尤其是加載套件的問題。你的'intern.json'是什麼樣的?如果您刪除了「intern.json」然後運行它,那麼實習會做什麼? – jason0x43

+0

只有:'{ \t 「插件」: 「node_modules /巴貝爾註冊/ lib目錄/ node.js的」, \t 「套房」: 「測試/單位/ test.js」 }'我有同樣的錯誤無論intern.json文件的內容 – Troopers