运行 来自 Node 的 Mocha 测试 - 'describe' 未定义
Run Mocha tests from Node - 'describe' is not defined
我正在尝试 运行 Mocha 测试,例如,在从 Node 程序中触发事件之后。我试图避免使用 child_process
。阅读 this wiki 页面后,我将我的代码设置如下:
var Mocha = require("mocha");
var Reporter = require("./reporter");
var mocha = new Mocha({
ui: "tdd",
reporter: "spec"
});
mocha.addFile("test.js");
mocha.run();
其中 test.js
具有有效的 mocha 测试。但是当我 运行 这个时,我不断得到 ReferenceError: describe is not defined
。为什么会这样? (当我在 Google 上搜索这个问题时,大多数解决方案都是关于 运行ning test.js
使用 node 而不是 mocha 的人。)
The BDD interface provides describe(), context(), it(), specify(), before(), after(), beforeEach(), and afterEach().
您已将 ui 设置为 "tdd":
The TDD interface provides suite(), test(), suiteSetup(), suiteTeardown(), setup(), and teardown():
var Mocha = require("mocha");
var Reporter = require("./reporter");
*File "<ipython-input-42-669e9b71bd81>", line 1
var Mocha = require("mocha");
^
SyntaxError: invalid syntax*
作为输出
1.describe() is not defined as it was not availabel in H2OFrame
我正在尝试 运行 Mocha 测试,例如,在从 Node 程序中触发事件之后。我试图避免使用 child_process
。阅读 this wiki 页面后,我将我的代码设置如下:
var Mocha = require("mocha");
var Reporter = require("./reporter");
var mocha = new Mocha({
ui: "tdd",
reporter: "spec"
});
mocha.addFile("test.js");
mocha.run();
其中 test.js
具有有效的 mocha 测试。但是当我 运行 这个时,我不断得到 ReferenceError: describe is not defined
。为什么会这样? (当我在 Google 上搜索这个问题时,大多数解决方案都是关于 运行ning test.js
使用 node 而不是 mocha 的人。)
The BDD interface provides describe(), context(), it(), specify(), before(), after(), beforeEach(), and afterEach().
您已将 ui 设置为 "tdd":
The TDD interface provides suite(), test(), suiteSetup(), suiteTeardown(), setup(), and teardown():
var Mocha = require("mocha");
var Reporter = require("./reporter");
*File "<ipython-input-42-669e9b71bd81>", line 1
var Mocha = require("mocha");
^
SyntaxError: invalid syntax*
作为输出
1.describe() is not defined as it was not availabel in H2OFrame