且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Webstorm 中运行 Mocha 测试

更新时间:2023-01-16 19:46:31

为 Mocha 添加配置:

Add a configuration for Mocha:

运行 ->编辑配置 ->按+"->选择摩卡".

表单字段:

节点解释器: your_node_executable_path

Node interpreter: your_node_executable_path

工作目录: root_path_of_your_app

Working directory: root_path_of_your_app

Mocha 包: mocha_path(通常在您的 node_modules 文件夹中).

Mocha package: mocha_path (normally within your node_modules folder).

测试目录: root_path_of_your_app \test

Test directory: root_path_of_your_app \test

默认情况下,Mocha 在 test 文件夹中查看测试,并在那里尝试运行 test.js.

By default Mocha looks the tests inside test folder and there, it tries to run test.js.

所有 Mocha 命令(--compilers--require 等)都可以包含在 mocha.opts 中.Mocha 尝试读取 \test\mocha.opts 中的这个文件.

All the Mocha commands (--compilers, --require, etc) can be included in mocha.opts. Mocha tries to read this file in \test\mocha.opts.

mocha.opts 每行需要一个命令.