☕️ Classic, reliable, trusted test framework for Node.js and the browser
fix: support modern RegExp flags in Mocha#grep (#5825)
Vamsik35413b661023
diff --git a/lib/mocha.js b/lib/mocha.jsindex d84784b5..a3bb26b0 100644--- a/lib/mocha.js+++ b/lib/mocha.js@@ -553,7 +553,7 @@ Mocha.prototype.fgrep = function (str) {Mocha.prototype.grep = function (re) {if (utils.isString(re)) {// extract args if it's regex-like, i.e: [string, pattern, flag]- var arg = re.match(/^\/(.*)\/([gimy]{0,4})$|.*/);+ var arg = re.match(/^\/(.*)\/([a-z]*)$|.*/);this.options.grep = new RegExp(arg[1] || arg[0], arg[2]);} else {this.options.grep = re;diff --git a/test/unit/grep.spec.js b/test/unit/grep.spec.jsindex a84f149f..55fdd4f2 100644--- a/test/unit/grep.spec.js+++ b/test/unit/grep.spec.js@@ -50,6 +50,9 @@ describe("Mocha", function () {// Keep the flagstest("/baz/i", "/baz/i");test("/bar/g", "/bar/g");+ test("/foo/u", "/foo/u");+ test("/foo/s", "/foo/s");+ test("/foo/v", "/foo/v");test("/^foo(.*)bar/g", "/^foo(.*)bar/g");});