I am trying to pull out a smoke suite from my regression suite written using the Jasmine framework (wdio-jasmine-framework
).
Is it possible to just add a tag on specific testcases in Jasmine?
I am trying to pull out a smoke suite from my regression suite written using the Jasmine framework (wdio-jasmine-framework
).
Is it possible to just add a tag on specific testcases in Jasmine?
In addition to the iamdanchiv's answer, with WebdriverIO ~7+ & Jasmine ~3.7+ (maybe with older versions too) you can add any text tag to your its and describes, and filter the specs to run by it.
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.
P.S.: I could not make multiple tags work together, but this is enough to select only smoke tests.
If I remember correctly from my Jasmine/Mocha days, there were several ways to achieve this. I'll detail a few, but I'm sure there might be some others too. Use the one that's best for you.
1. Use the
it.skip()
statement inside a conditional operator expression to define the state of a test-case (e.g: in the case of asmokeRun
, skip the non-smoke tests using:(smokeRun ? it.skip : it)('not a smoke test', () => { // > do smth here < });
).Here is an extended example:
2. Use
it.only()
to achieve mainly the same effect, the difference being the test-case refactor workload. I'll summarize these ideas as:it.skip()
approach;it.only()
approach;You can read more about
pending-tests
here.3. Use the runtime skip (
.skip()
) in conjunction with some nesteddescribe
statements.It should look something like this:
!Note: These are working examples! I tested them using WebdriverIO's recommended Jasmine Boilerplace project.
!Obs: There multiple ways to filter Jasmine tests, unfortunately only at a test-file(testsuite) level (e.g: using
grep
piped statements, or the built-in WDIOspecs
&exclude
attributes).