@wdio/mocha-framework

  • Version 10.2.0
  • Published
  • 70.7 kB
  • 6 dependencies
  • MIT license

Install

npm i @wdio/mocha-framework
yarn add @wdio/mocha-framework
pnpm add @wdio/mocha-framework

Overview

A WebdriverIO plugin. Adapter for Mocha testing framework.

Index

Variables

variable adapterFactory

const adapterFactory: { init?: Function };

    Classes

    class MochaAdapter

    class MochaAdapter {}
    • Mocha runner

    constructor

    constructor(
    _cid: string,
    _config: ParsedConfiguration,
    _specs: string[],
    _capabilities: WebdriverIO.Capabilities,
    _reporter: EventEmitter
    );

      method emit

      emit: (
      event: string,
      payload: Record<string, unknown>,
      err?: MochaError
      ) => void;

        method getSyncEventIdEnd

        getSyncEventIdEnd: (type: EventTypes) => string;

          method getSyncEventIdStart

          getSyncEventIdStart: (type: EventTypes) => string;

            method getUID

            getUID: (message: FrameworkMessage) => string;

              method hasTests

              hasTests: () => boolean;

                method init

                init: () => Promise<this>;

                  method prepareMessage

                  prepareMessage: (
                  hookName: keyof Services.HookFunctions
                  ) => import('./types.js').FormattedMessage;

                    method run

                    run: () => Promise<number>;

                      method setBrowser

                      setBrowser: (browser: WebdriverIO.Browser) => void;

                        method wrapHook

                        wrapHook: (
                        hookName: keyof Services.HookFunctions
                        ) => () => Promise<void | unknown[]>;
                        • Hooks which are added as true Mocha hooks need to call done() to notify async

                        Interfaces

                        interface FormattedMessage

                        interface FormattedMessage {}

                          property body

                          body?: string;

                            property cid

                            cid?: string;

                              property context

                              context?: unknown;

                                property currentTest

                                currentTest?: string;

                                  property duration

                                  duration?: number;

                                    property error

                                    error?: MochaError;

                                      property file

                                      file?: string;

                                        property fullTitle

                                        fullTitle?: string;

                                          property hookKind

                                          hookKind?: Extract<
                                          Frameworks.HookKind,
                                          'beforeAll' | 'beforeEach' | 'afterEach' | 'afterAll'
                                          >;
                                          • the kind of a hook event, as @wdio/reporter reads it.

                                            Modifiers

                                            • @experimental

                                          property hookSuiteUid

                                          hookSuiteUid?: string;
                                          • the uid of the suite that declares an all-hook.

                                            Modifiers

                                            • @experimental

                                          property parent

                                          parent?: string;

                                            property passed

                                            passed?: boolean;

                                              property pending

                                              pending?: boolean;

                                                property specs

                                                specs?: string[];

                                                  property title

                                                  title?: string;

                                                    property type

                                                    type: string;

                                                      property uid

                                                      uid?: string;

                                                        interface FrameworkMessage

                                                        interface FrameworkMessage {}

                                                          property err

                                                          err?: MochaError;

                                                            property payload

                                                            payload?: unknown;

                                                              property type

                                                              type: string;

                                                                interface MochaError

                                                                interface MochaError {}

                                                                  property actual

                                                                  actual: unknown;

                                                                    property expected

                                                                    expected: unknown;

                                                                      property message

                                                                      message: string;

                                                                        property name

                                                                        name: string;

                                                                          property stack

                                                                          stack: string;

                                                                            property type

                                                                            type: string;

                                                                              interface MochaOpts

                                                                              interface MochaOpts {}

                                                                                property allowUncaught

                                                                                allowUncaught?: boolean;
                                                                                • Propagate uncaught errors?

                                                                                property asyncOnly

                                                                                asyncOnly?: boolean;
                                                                                • Force done callback or promise?

                                                                                property bail

                                                                                bail?: boolean;
                                                                                • Bail after first test failure?

                                                                                property checkLeaks

                                                                                checkLeaks?: boolean;
                                                                                • Check for global variable leaks?

                                                                                property delay

                                                                                delay?: boolean;
                                                                                • Delay root suite execution?

                                                                                property failHookAffectedTests

                                                                                failHookAffectedTests?: boolean;
                                                                                • Report tests skipped by a failing before or beforeEach hook as failed. WebdriverIO defaults this to true.

                                                                                property fgrep

                                                                                fgrep?: string;
                                                                                • Test filter given string.

                                                                                property forbidOnly

                                                                                forbidOnly?: boolean;
                                                                                • Tests marked only fail the suite?

                                                                                property forbidPending

                                                                                forbidPending?: boolean;
                                                                                • Pending tests fail the suite?

                                                                                property fullTrace

                                                                                fullTrace?: boolean;
                                                                                • Full stacktrace upon failure?

                                                                                property global

                                                                                global?: string[];
                                                                                • Variables expected in global scope.

                                                                                property grep

                                                                                grep?: RegExp | string;
                                                                                • Test filter given regular expression.

                                                                                property invert

                                                                                invert?: boolean;
                                                                                • Invert test filter matches?

                                                                                property maxParallelContexts

                                                                                maxParallelContexts?: number;
                                                                                • Maximum number of browsing contexts (windows) to use in parallel. Runs a pool of this many slots, each running one test at a time in its own window. A slot opens its next window while its test runs and closes the previous one in the background, so up to three times this many windows can be open briefly. os.cpus().length

                                                                                property parallelMode

                                                                                parallelMode?: 'contexts' | 'userContexts';
                                                                                • Enable parallel test execution within a spec file. Each it() block runs simultaneously in its own browsing context (window). Requires a WebDriver Bidi session AND the 'wdio:experimentalBiDiCommands': true capability; if either is missing, tests run sequentially with a warning.

                                                                                  - 'contexts': windows share the default user context, so cookies, localStorage and service workers are shared across concurrent tests. - 'userContexts': each test gets its own user context, so storage is isolated per test. Every test pays its own login cost. Throws if the driver does not support browser.createUserContext.

                                                                                  In both modes browser.mock() inside a test only intercepts that test's context. before()/after() run once per test, only mochaOpts.timeout applies, and bail/retries are not supported.

                                                                                  See Also

                                                                                  • https://webdriver.io/docs/parallel-tests undefined (sequential execution)

                                                                                property require

                                                                                require?: string[];
                                                                                • The require option is useful when you want to add or extend some basic functionality (WebdriverIO framework option).

                                                                                property retries

                                                                                retries?: number;
                                                                                • Number of times to retry failed tests.

                                                                                property timeout

                                                                                timeout?: number | string;
                                                                                • Timeout threshold value.

                                                                                property ui

                                                                                ui?: 'bdd' | 'tdd' | 'qunit' | 'exports';
                                                                                • Set test UI to one of the built-in test interfaces.

                                                                                Namespaces

                                                                                namespace global

                                                                                namespace global {}

                                                                                  namespace global.WebdriverIO

                                                                                  namespace global.WebdriverIO {}

                                                                                    interface MochaOpts

                                                                                    interface MochaOpts extends MochaOptsImport {}

                                                                                      Package Files (2)

                                                                                      Dependencies (6)

                                                                                      Dev Dependencies (0)

                                                                                      No dev dependencies.

                                                                                      Peer Dependencies (0)

                                                                                      No peer dependencies.

                                                                                      Badge

                                                                                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@wdio/mocha-framework.

                                                                                      • Markdown
                                                                                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@wdio/mocha-framework)
                                                                                      • HTML
                                                                                        <a href="https://www.jsdocs.io/package/@wdio/mocha-framework"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>