Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wdio/mocha-framework

Package Overview
Dependencies
Maintainers
3
Versions
355
Alerts
File Explorer

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.2.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
311K
decreased by-16.12%
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

Keywords

FAQs

Package last updated on 01 Nov 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc