Grep argument is ignored
What are you trying to achieve?
I'm trying to create a npm script which will only run tests marked with '@stable' tag in scenario name.
Using the npm script codeceptjs run --steps --grep @stable
What do you get instead?
Different test, one without '@stable' tag, is executed.
I've tried to debug the issue. I noticed that options.grep is passed to mocha, however it is overwritten with the first test file. It is overwritten after return Mocha.prototype.loadFiles.call(mocha, fn); is called inside mochaFactory.js
https://github.com/Codeception/CodeceptJS/blob/72b46931dbcdc89b9a309b3748ad8db29fb7e8bf/lib/mochaFactory.js#L48
Example options.grep: Before Mocha.prototype.loadFiles.call(mocha, fn): '@stable' After Mocha.prototype.loadFiles.call(mocha, fn): 'My other scenario name from .files variable'
so for example, when I call npm run codeceptjs run --grep @stable the first test from '*_test.js' tests glob is executed.
Details
- CodeceptJS version: ^1.3.2
- NodeJS Version: 8.11.3
- Operating System: Windows Server 2012 R2, x64
- Puppeteer: ^1.3.0
I've found the problem solution. We've had a couple of Scenario.only() uses in our testing solution.
When loadFiles is run the context.Scenario.only is run where option.grep of mocha is overriden by calling mocha.grep.
This issue can be closed. Or I could create a PR with some warning, perhaps '--grep argument is ignored due to Scenario.only use'
sorry, miscommented