简体   繁体   English

在Webstorm中运行Mocha测试

[英]Running Mocha tests in Webstorm

I'm running Mocha tests for React in Webstorm's terminal window using the following NPM start command: 我正在使用以下NPM启动命令在Webstorm的终端窗口中运行React的Mocha测试:

"tsc && mocha --compilers js:babel-core/register --require ./test_helper.js \"test/**/*.@(js|jsx)\" --watch --watch-extensions js,jsx,tsx"

How do I create a Webstorm Mocha configuration so that I can run tests in Webstorm's test window? 如何创建Webstorm Mocha配置以便我可以在Webstorm的测试窗口中运行测试?

Thanks. 谢谢。

Add a configuration for Mocha: 为Mocha添加配置:

Run -> Edit Configurations -> Press "+" -> Select "Mocha".

Fields of the form: 表格的字段:

Node interpreter: your_node_executable_path 节点解释器: your_node_executable_path

Working directory: root_path_of_your_app 工作目录: root_path_of_your_app

Mocha package: mocha_path (normally within your node_modules folder). Mocha包: mocha_path(通常位于node_modules文件夹中)。

Test directory: root_path_of_your_app \\test 测试目录: root_path_of_your_app \\ test

By default Mocha looks the tests inside test folder and there, it tries to run test.js . 默认情况下,Mocha查看test文件夹中的测试,然后尝试运行test.js

All the Mocha commands ( --compilers , --require , etc) can be included in mocha.opts . 所有Mocha命令( --compilers ,-- --require等)都可以包含在mocha.opts Mocha tries to read this file in \\test\\mocha.opts . Mocha尝试在\\test\\mocha.opts读取此文件。

mocha.opts requires one command per line. mocha.opts每行需要一个命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM