2016-12-29 52 views
6

摩卡人有沒有辦法列出所有由測試跑步者收集的測試而不執行它們?列出所有摩卡測試而不執行它們

E.g.如果有規格看起來像:

describe('First', function() { 
    it('should test something', function() { 
     ... 
    }) 
}); 

describe('Second', function() { 
    it('should test something else', function() { 
     ... 
    }) 
}); 

話,我想類似的測試記者產生的輸出控制檯輸出,但不執行實際測試中,像這樣:

First 
    should test something 
Second 
    should test something else 

UPD:

目前我正在提取所有describe s和it s與正則表達式,但尋找一個更乾淨的解決方案。

回答

1

將所有描述塊包裝在describe塊中,並且跳過它。

describe.skip('Outline', function() { 
    describe('First', function() { 
     it('should test something', function() { 
      ... 
     }) 
    }); 

    describe('Second', function() { 
     it('should test something else', function() { 
      ... 
     }) 
    }); 
}); 
+0

雖然這會打印出測試列表,但它並不能真正解決問題。我沒有看到如何將這個解決方案用於測試存儲在多個文件中的項目,並且需要定期檢索測試列表。 – Vader

+1

你真正想要的是'--dry-run'選項,它已經被提出,但從未被合併。請參閱[摩卡拉請求#1070](https://github.com/mochajs/mocha/pull/1070) – dNitro

+0

是的,這正是我正在尋找的東西,可悲的是它沒有被接受。 – Vader