如何将具有大量收益和合计的大型npm测试库转换为摩卡测试?

时间:2019-04-12 11:08:57

标签: node.js mocha bdd

我有大量的测试代码库,使用yield,co编写,即像这样的- co(runV1Tests).catch(fail);

测试包装器功能有点像这样,其中co包装了整个功能:

function * runV1Tests() {
    yield testListA();
    yield testListB();

在每个测试中,单个测试的编写方式如下:

function * testCreateCloudProviderV2() {
    x = yield * someOtherFunction();
    assert(x == 1);

以此类推。

我试图天真地将这些测试转换为使用mocha描述,但是我遇到了可怕的“意外的严格模式保留字”错误...

+describe("Must pass V2 Tests", function() {
+    it("should pass all these tests", function() {
+          yield  ListA();
+          yield  ListB();

然后我尝试像这样包装it("should pass all these tests", function() {it("should pass all these tests", co(function() {,但这似乎没有用。

那么,如果我想将很多在各处都使用yield和yield *的npm测试包装到mocha或其他具有更多声明性输出和统计信息的测试框架中,那将是一个很好的习惯用法?

0 个答案:

没有答案