簡體   English   中英

摩卡Grep Regex用於特定測試

[英]Mocha Grep Regex for specific test

我有以下項目https://github.com/invertednz/mocha-example

它具有4個測試:

starts should return -1 when the value is not present
should return -1 when the value is not present
should return -1 when the value is not present2
should return -1 when the value is not present 3

我想使用--grep,以便僅運行“當不存在該值時應返回-1”

我想使用“ ^,當不存在該值時應返回-1”,但我相信describe部分將其弄亂了。

上面的例子代表了一個人為的例子,我從API返回一個需要運行的測試名稱,然后我只想運行那個特定的測試,我不確定可能存在的所有測試名稱。

例如,在這種情況下,我想知道我想運行“當值不存在時應返回-1”,但不知道“當值不存在時啟動應返回-1”。

我想知道是否可以使用describe這樣的描述:

Array #indexOf().should return -1 when the value is not present$

我應該使用什么正則表達式?

對於這組特定的字符串,您可以使用以下簡單內容:

^(?!starts).*present$

這將簡單地確保通過使用負前瞻來確保不匹配第一個字符串,而第3個和第4個字符串則由於匹配在present之后立即結束而沒有匹配。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM