Skip to content

Instantly share code, notes, and snippets.

@adaemon
adaemon / Using Mocha Tags in WDIO Mocha Plugin
Last active October 3, 2023 06:40
WebdriverIO Mocha Plugin : Using Mocha Tags
WDIO Mocha plugin is an useful adapter to use Mocha in WDIO. Mocha options can be provided through wdio config file or through command line argument. To invoke WDIO from npm scripts passing command line arguments is tricky.
Mocha Tags are useful to run specific methods tagged by common name. Requirements like running smoke test, remote, local, headless, fast, slow tests can be done using tags. https://github.com/mochajs/mocha/wiki/Tagging
Let say i have a package.json scripts section like below
"scripts": {
"smoke": "node node_modules/webdriverio/bin/wdio conf/wdio.conf.js --mochaOpts.grep=@Smoke",
"slow": "node node_modules/webdriverio/bin/wdio conf/wdio.conf.js --mochaOpts.grep=@Slow",
"fast": "node node_modules/webdriverio/bin/wdio conf/wdio.conf.js --mochaOpts.grep=@Fast"