The current behavior
const mochaConfig: MochaOptions = {
...config.mocha,
grep: taskArgs.grep,
};
prevents plugins from making use of config.mocha.grep as it will be unset if the option is not coming from the cli.
I would suggest this type of logic instead
if (taskArgs.grep !== undefined) {
mochaConfig.grep = taskArgs.grep;
}