我使用Intern 4.0(是的!我知道!这是一个alpha版本。但是我想在es6中重写我的代码和单元测试。)
我安装了npm包“intern 4.0.0-alpha.4”,我在es6中重写了代码,单元测试和套件。
但是我无法进行测试。
我想从npm脚本运行测试:我编辑了我的package.json
文件来获取:
"scripts": {
"test": "node_modules/.bin/intern"
}
我也尝试过:
"scripts": {
"test": "node_modules/.bin/intern config=intern.json"
}
或与inter-cli:
"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 npm@4.4.4
3 info using node@v6.10.3
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle myproject@0.0.1~pretest: myproject@0.0.1
6 silly lifecycle myproject@0.0.1~pretest: no script for pretest, continuing
7 info lifecycle myproject@0.0.1~test: myproject@0.0.1
8 verbose lifecycle myproject@0.0.1~test: unsafe-perm in lifecycle true
9 verbose lifecycle myproject@0.0.1~test: PATH: ...
10 verbose lifecycle myproject@0.0.1~test: CWD: D:\Temp\myproject
11 silly lifecycle myproject@0.0.1~test: Args: [ '/d /s /c', 'intern config=intern.json' ]
12 silly lifecycle myproject@0.0.1~test: Returned: code: 1 signal: null
13 info lifecycle myproject@0.0.1~test: Failed to exec test script
14 verbose stack Error: myproject@0.0.1 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 myproject@0.0.1
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 myproject@0.0.1 test: `intern config=intern.json`
23 error Exit status 1
24 error Failed at the myproject@0.0.1 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 ]
有你的想法吗?
答案 0 :(得分:1)
您可以使用
"scripts": {
"test": "intern"
}
由于intern
是node_modules/.bin
中的bin脚本,因此您无需在node_modules/.bin
中使用package.json
。
只是为了验证,您可以尝试运行
node node_modules\.bin\intern
实习生应该运行您在intern.json
中配置的套件。