0

We are on latest 8.X WebdriverIO version and latest Jasmine 4.X at this moment, using latest Node 18.X.

In my Wdio.conf.js file I have suite:

all: [ 'path/test1.js', 'path/test2.js'],

test1.js has a Describe with value "SMOKE test 1", while test2.js has "test 2".

I want to run --suite=all but exclude all files that DOESN'T contain "SMOKE" in the title, or run --suite=all but include only tests which contains "SMOKE" in the title. Is this possible, and how? I'm having real troubles finding examples for this case. Can we use grep for this example somehow? I don't have an idea how can we do it.

Basically, the idea is to run only smoke test from some suite. We are not using Mocha and Cucumber runners which have additional tagging, so we are basically running suites all the time. I don't want to create more suites and divide tests in separate suites, we have to many test files.

I tried following the documentation, but I'm having troubles using their example: grep -r -l --include "*.js" "myText" | wdio wdio.conf.js

1 Answer 1

1

with WebdriverIO 7.21 & Jasmine 3.7 the following works stable, hope it's not changed in Wdio 8 or Jasmine 4. At least the jasmineOpts (instead of older jasmineNodeOpts) works fine in wdio 7, but is correctly mentioned from wdio 8 docs.

A working package.json script is using the Jasmine's grep:

"smoketest": "wdio run wdio.local.conf.js --suite=temp --jasmineOpts.grep=_smoke"

where:

--suite=temp is defined in the wdio.local.conf.js suites and runs only those spec files,

--jasmineOpts.grep=_smoke finds '_smoke' part in the test (it) titles AND describe titles inside the above spec files and runs only them.

This would run the full describe

describe(`Suite 1 _smoke any other text`, () => {
   it('Test 1-1', async () => {});
   it('Test 1-2', async () => {});
});

and tests from another describe(s) like:

it('Test 2-1 _smoke is for smoke runs', async () => {});

Non-matching tests (its) are skipped.

_smoke can be any other text tag you add to the titles.


Additional info:

  1. Of course, you remember to add an extra -- to run an npm script with extra options :) (I used to forget)))

package.json script:

"localtest": "wdio run wdio.local.conf.js --suite=temp"

command line:

$ npm run localtest -- --jasmineOpts.grep=_smoke
> wdio run wdio.local.conf.js --suite=temp --jasmineOpts.grep=_smoke

--spec=_smoke would find and launch the filenames that contain '_smoke' (e.g. test1_smoke.js), not the Describe names, but may be useful. Wdio docs here.

Please note that "When the --spec option is provided, it will override any patterns defined by the config or capability level's specs parameter", so --suite=temp --spec=_smoke will run all files from the config suite named temp AND all files with matching filename.


I could not make --grep=_smoke work, it starts all suites and tests. Seems to have no effect for Wdio runner + Jasmine.

Also failed with multiple tags like --jasmineOpts.grep='@describe_tag||@test_tag', --jasmineOpts.grep='@describe_tag|@test_tag', --jasmineOpts.grep='@describe_tag&&@test_tag'. Maybe someone will have more luck.

Hope this helps someone :)

2
  • I managed to run my whole suite and use --jasmineOpts.grep to exclude everything that doesn't have desired tag, and it works perfectly! Thank you so much for reply, I can now re-arrange the structure of the tests not to have so many foldesr, but instead we can just use the custom naming in describe blocks and run based on them. So good!
    – Goran
    Commented Apr 6, 2023 at 6:35
  • Let me also share the versions of packages. Using: - wdio 8.4 (@wdio set of packages on this version) - jasmine 4.3.1 "@wdio/cli": "^8.4.0", "@wdio/jasmine-framework": "^8.4.0", "@wdio/local-runner": "^8.4.0", "@wdio/spec-reporter": "^8.4.0"
    – Goran
    Commented Apr 6, 2023 at 6:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.