WDIO Mocha Framework Adapter

0.6.4 · abandoned · verified Tue Apr 21

The `wdio-mocha-framework` package, specifically version 0.6.4, served as an adapter to integrate the Mocha testing framework with WebdriverIO. Released many years ago, it allowed users to write their automated browser tests using Mocha's BDD (Behavior Driven Development) or TDD (Test Driven Development) interfaces within the WebdriverIO test runner. Its primary function was to parse Mocha tests, execute them via WebdriverIO's browser automation capabilities, and report results. Key configurations included `mochaOpts` for passing options directly to Mocha, and `require`/`compilers` for custom setup files or transpilers. This standalone package has since been abandoned; its last stable version, 0.6.4, was published in 2017. Modern WebdriverIO projects (v5+) utilize `@wdio/mocha-framework`, which is part of the main WebdriverIO monorepo and receives active maintenance and updates, reflecting a continuous release cadence in alignment with WebdriverIO's own major versions.

Common errors

Warnings

Install

Quickstart

Demonstrates the basic `wdio.conf.js` setup for using the `wdio-mocha-framework` with WebdriverIO v4. It shows how to specify Mocha as the framework, configure `mochaOpts`, and includes a basic runnable Mocha test file.

/* wdio.conf.js */
// This configuration file is for WebdriverIO v4, compatible with wdio-mocha-framework 0.6.4
module.exports = {
  // Define where your test files are located
  specs: [
    './tests/**/*.js'
  ],

  // Capabilities (browser settings)
  capabilities: [{
    browserName: 'chrome'
  }],

  // Log level
  logLevel: 'info',

  // Reporters
  reporters: ['spec'],

  // Specify the framework to use. For Mocha, use 'mocha'.
  framework: 'mocha',

  // Options for Mocha
  mochaOpts: {
    ui: 'bdd',
    timeout: 60000, // Example: set a default timeout for all tests
    // You can also specify custom require files here for test setup or transpilation
    // require: ['./hooks/mocha-setup.js'],
    // compilers: ['coffee:foo'], // Example for transpilers like CoffeeScript
  },
  // ... other WebdriverIO configuration options
};


/* Example test file (e.g., ./tests/example.js) */
describe('My WebdriverIO application', () => {
  it('should navigate to a page and check its title', async () => {
    await browser.url('https://webdriver.io');
    const title = await browser.getTitle();
    console.log(`Page title: ${title}`);
    // In a real project, you would typically use an assertion library like @wdio/expect
    // For this old version, a simple JS check suffices, or an older assertion library.
    if (!title.includes('WebdriverIO')) {
      throw new Error('Title does not contain expected text');
    }
  });

  it('should demonstrate a skipped test', function() {
    this.skip(); // Mocha's way to skip a test
  });
});

view raw JSON →