New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@wdio/mocha-framework

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wdio/mocha-framework

A WebdriverIO plugin. Adapter for Mocha testing framework.

9.11.0
Version published
Weekly downloads
455K
-1.34%
Maintainers
3
Weekly downloads
 
Created

What is @wdio/mocha-framework?

@wdio/mocha-framework is a WebdriverIO plugin that integrates the Mocha testing framework. It allows you to write and run tests using Mocha's BDD, TDD, and other interfaces, providing a robust environment for end-to-end testing of web applications.

What are @wdio/mocha-framework's main functionalities?

BDD Interface

This feature allows you to use Mocha's BDD interface to describe your tests in a natural language style. The code sample demonstrates a simple test that opens the Google homepage and checks the title.

const { describe, it } = require('mocha');
const assert = require('assert');

describe('Google Search', () => {
  it('should open the Google homepage', async () => {
    await browser.url('https://www.google.com');
    const title = await browser.getTitle();
    assert.strictEqual(title, 'Google');
  });
});

TDD Interface

This feature allows you to use Mocha's TDD interface to structure your tests. The code sample demonstrates a simple test that opens the Google homepage and checks the title.

const { suite, test } = require('mocha');
const assert = require('assert');

suite('Google Search', () => {
  test('should open the Google homepage', async () => {
    await browser.url('https://www.google.com');
    const title = await browser.getTitle();
    assert.strictEqual(title, 'Google');
  });
});

Hooks

This feature allows you to use Mocha's hooks (before, after, beforeEach, afterEach) to set up and tear down conditions for your tests. The code sample demonstrates using hooks to open the Google homepage before tests and delete the session after tests.

const { describe, it, before, after } = require('mocha');
const assert = require('assert');

before(async () => {
  await browser.url('https://www.google.com');
});

after(async () => {
  await browser.deleteSession();
});

describe('Google Search', () => {
  it('should have the correct title', async () => {
    const title = await browser.getTitle();
    assert.strictEqual(title, 'Google');
  });
});

Other packages similar to @wdio/mocha-framework

FAQs

Package last updated on 05 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts