codeceptjs / CodeceptJS

Supercharged End 2 End Testing Framework for NodeJS

Home Page:http://codecept.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

--grep is case insensitive in the mode "dry-run" whereas case sensitive in the mode "run"

mirao opened this issue · comments

What are you trying to achieve?

I would expect that "run" and "dry-run" modes have the same behavior related to case-sensitivity of tags.
Personally I prefer case-insensitive tags so that I don't want to think if I need to pass the tag @problem or @Problem
https://codecept.io/advanced/#tags doesn't say anything about case sensitivity.

What do you get instead?

run is "case sensitive" when using --grep

$ codeceptjs run --grep @Problem
CodeceptJS v3.5.14 #StandWithUkraine
Using test root "/home/mirao/workspace/tmp"


  OK  | 0 passed   // 0ms

dry-run is "case insensitive" when using --grep

$ codeceptjs dry-run --grep @Problem
Tests from /home/mirao/workspace/tmp:

My @problem -- /home/mirao/workspace/tmp/My_test.ts -- 1 tests
  ☐ test something

  Total: 1 suites | 1 tests  

--- DRY MODE: No tests were executed ---

Provide test source code if related

Feature('My').tag("@problem");

Scenario('test something',  ({ I }) => {
    I.amOnPage('https://www.google.com');
});

Details

  • CodeceptJS version: 3.5.14
  • NodeJS Version: v18.19.1
  • Operating System: Ubuntu 22.04
  • Configuration file:
import { setHeadlessWhen, setCommonPlugins } from '@codeceptjs/configure';
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();

export const config: CodeceptJS.MainConfig = {
  tests: './*_test.ts',
  output: './output',
  helpers: {
    Playwright: {
      browser: 'chromium',
      url: 'http://localhost',
      show: true
    }
  },
  include: {
    I: './steps_file'
  },
  name: 'tmp'
}
➜  codeceptjs-rest-demo git:(master) ✗ npx codeceptjs dry-run               
Tests from /Users/t/Desktop/projects/codeceptjs-rest-demo:

DELETE tests -- /Users/t/Desktop/projects/codeceptjs-rest-demo/src/DELETE_test.ts -- 1 tests
  ☐ Verify deleting a user
GET tests -- /Users/t/Desktop/projects/codeceptjs-rest-demo/src/GET_test.ts -- 4 tests
  ☐ Verify a successful call @Jaja
  ☐ Verify a not found call
  ☐ Verify getting a single user @jaja
  ☐ Verify getting list of users @jaja
POST tests -- /Users/t/Desktop/projects/codeceptjs-rest-demo/src/POST_test.ts -- 2 tests
  ☐ Verify creating new user
  ☐ Verify uploading a file
PUT tests -- /Users/t/Desktop/projects/codeceptjs-rest-demo/src/PUT_test.ts -- 1 tests
  ☐ Verify creating new user

  Total: 4 suites | 8 tests  

--- DRY MODE: No tests were executed ---
➜  codeceptjs-rest-demo git:(master) ✗ npx codeceptjs dry-run --grep "@jaja"
Tests from /Users/t/Desktop/projects/codeceptjs-rest-demo:


  Total: 0 suites | 0 tests  

--- DRY MODE: No tests were executed ---
➜  codeceptjs-rest-demo git:(master) ✗ npx codeceptjs dry-run --grep "@Jaja"
Tests from /Users/t/Desktop/projects/codeceptjs-rest-demo:


  Total: 0 suites | 0 tests  

--- DRY MODE: No tests were executed ---

When I'm passing the grep pattern, it doesn't return me anything.

I think --grep in the dry-run mode works only for tags at Feature().
Is it your case?

Oh, really? I thought it is applicable to all. 😅

It looks like --grep in the run mode is handled by mocha (RegExp) whereas --grep in the dry-run is handled by CodeceptJS itself.