如何在WebStorm IDE中运行jasmine-node

问题描述 投票:2回答:3

我安装了nodejs和jasmine-node,它在命令行中运行。

WebStorm Runner的配置:

  1. 节点参数:jasmine-node --config endpoint ServerAddress:8083
  2. 工作目录:G:\NPWorkDir\frisby
  3. JavaScript文件:src\protocol\find_spec.js

WebStorm Terminal:

"C:\Program Files\JetBrains\WebStorm\bin\runnerw.exe" "G:\Program 
Files\nodejs\node.exe" jasmine-node --config endpoint ServerAddress:8083 
G:\NPWorkDir\frisby\src\
protocol\find_spec.js

module.js:471
throw err;
^

Error: Cannot find module 'G:\NPWorkDir\tester-frisbys\jasmine-node'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3

Process finished with exit code 1
webstorm jasmine-node
3个回答
2
投票

你必须指定node_modules\jasmine-node\bin\jasmine-node作为JavaScript文件,传递--config选项和你.js文件作为应用程序参数,如;

enter image description here


0
投票

完整配置以运行jsmine-node:

  1. 使用-save参数安装jasmine节点: npm install jasmine-node -save
  2. 使用以下参数配置WebStorm runner: javaScript文件-home directiory- \ AppData \ Roaming \ npm \ node_modules \ jasmine-node \ lib \ jasmine-node \ cli.js 应用程序参数://测试文件的路径

0
投票

我的答案使用linux而不是windows路径名!

我会推荐jasmine而不是jasmine-node,它似乎更实际。使用创建配置

./node_modules/.bin/jasmine init

如有必要,请编辑jasmine.json

我会在package.json中创建一个npm脚本:

"scripts": {
  "test": "node_modules/.bin/jasmine",
  ...
},

并在Webstorm中将其定义为npm脚本;命令:run,script:test

© www.soinside.com 2019 - 2024. All rights reserved.