CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Regex doesn't works

Open BrunoExterckotter opened this issue 9 years ago • 4 comments

What are you trying to achieve?

I'm using regex to filter and don't run scripts whith @tag negated in regex

What do you get instead?

(?!.*@tagxyz) was unexpected in the moment.

Provide test source code if related Feature('@ABC @tagxyz');

Run using: codeceptjs run --grep "(?=.@ABC)^(?!.@tagxyz)"

Reference: http://codecept.io/advanced/

Details

  • CodeceptJS version: "^1.0.0",

  • NodeJS Version: "v6.11.2"

  • Operating System: Windows 10 Pro x64 *WebDriverIO: "^4.8.0"

BrunoExterckotter avatar Oct 18 '17 19:10 BrunoExterckotter

@BrunoExterckotter Could you please provide error message from console? I think that maybe you should escape several symbols in your script like this: codeceptjs run --grep "\(\?\=\.\*@ABC\)\^\(\?\!\.\*@tagxyz)"

APshenkin avatar Oct 19 '17 08:10 APshenkin

image

image

When I am executing with escape, using only the first part of regex, apparently the result is success, but the test doesn't execute. The second command was not working with the first apparently. Am I doing something wrong?

BrunoExterckotter avatar Oct 19 '17 10:10 BrunoExterckotter

@BrunoExterckotter Are you still have problems with the grep option?

I think this is a limitation of mocha as the --grep parameter is passed directly to mocha. Though you can use the --invert --grep '@tagxyz' which will match everything does not have the @tagxyz.

Otherwise I would recommend splitting up your tests into different folders and then define different codeceptjs config files for each. If you use the Dynamic Configuration then you can require common configuration and only change the grep field.

reubenmiller avatar Feb 26 '18 19:02 reubenmiller

@reubenmiller I'm not sure if I should open a new issue for this, but I'm having similiar problem with grep option. (Edit: I've created new issue #1200 ) Although I don't use the inverse regex.

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

so for example, when I call npm run codeceptjs run --grep @stable the test first test from 'tests' glob is executed.

codeceptjs 1.3.2 node: 8.11.3 windows 10 64x

DawidTabak avatar Sep 04 '18 11:09 DawidTabak