How to use the mocha/lib/suite.create function in mocha

To help you get started, we’ve selected a few mocha examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dotnetprofessional / LiveDoc / packages / livedoc-mocha / _src / app / LiveDocUI.ts View on Github external
function processBddDescribe(suites: mocha.ISuite, type: string, title: string, file: string): mocha.ISuite {
        // This is a legacy describe/context test which doesn't support
        // the features of livedoc
        let suiteParent: model.MochaSuite = null;
        if (suites[0].livedoc && !suites[0].root) {
            suiteParent = suites[0].livedoc;
            // Verify that this not part of a livedoc feature
            if (isLiveDocType(suites[0].livedoc.type)) {
                // seems this is using mixed languages which is not supported    
                throw new model.ParserException(`This ${suites[0].livedoc.type} is using bdd syntax, did you mean to use scenario instead?`, title, file);
            }
        }

        const suite = mochaSuite.create(suites[0], title);
        const childSuite = new model.MochaSuite(suiteParent, title, type);
        childSuite.filename = file;
        addBddContext(suite, childSuite);

        return suite;
    }
}
github dotnetprofessional / LiveDoc / packages / livedoc-mocha / _src / app / LiveDocUI.ts View on Github external
livedocContext.scenarioId = livedocContext.parent.scenarioCount;
                        // Fall through on purpose
                        case "Scenario Outline":
                            livedocContext.scenario = suiteDefinition as model.Scenario;
                            break;
                    }

                    // Specific logic for Scenario Outlines
                    if (type === "Scenario Outline") {
                        // Setup the basic context for the scenarioOutline

                        const scenarioOutline = suiteDefinition as model.ScenarioOutline;
                        for (let i = 0; i < scenarioOutline.examples.length; i++) {
                            const currentScenario = scenarioOutline.examples[i];
                            context = currentScenario.getScenarioContext();
                            var scenarioExampleSuite = mochaSuite.create(suites[0], currentScenario.displayTitle);

                            livedocContext = addLiveDocContext(scenarioExampleSuite, feature, type);
                            livedocContext.scenario = currentScenario;
                            livedocContext.parent.scenarioCount += 1;
                            livedocContext.scenarioId = scenarioExampleSuite.parent.livedoc.scenarioCount;
                            suites.unshift(scenarioExampleSuite);

                            if (livedocContext.parent.afterBackground) {
                                scenarioExampleSuite.afterAll(() => {
                                    return livedocContext.parent.afterBackground();
                                });
                            };

                            if (opts.pending || suites[0].isPending() || mocha.livedoc.shouldMarkAsPending(suiteDefinition.tags)) {
                                (scenarioExampleSuite as any).pending = true;
                            }
github Codeception / CodeceptJS / lib / ui.js View on Github external
context.Feature = function (title, opts) {
      if (suites.length > 1) {
        suites.shift();
      }

      afterAllHooks = [];
      afterEachHooks = [];
      afterAllHooksAreLoaded = false;
      afterEachHooksAreLoaded = false;

      const suite = Suite.create(suites[0], title);
      if (!opts) opts = {};
      suite.timeout(0);

      if (opts.retries) suite.retries(opts.retries);
      if (opts.timeout) suite.timeout(opts.timeout);

      suite.tags = title.match(/(\@[a-zA-Z0-9-_]+)/g) || []; // match tags from title
      suite.file = file;
      suite.fullTitle = () => `${suite.title}:`;
      suites.unshift(suite);
      suite.beforeEach('codeceptjs.before', () => scenario.setup(suite));
      afterEachHooks.push(['finalize codeceptjs', () => scenario.teardown(suite)]);

      suite.beforeAll('codeceptjs.beforeSuite', () => scenario.suiteSetup(suite));
      afterAllHooks.push(['codeceptjs.afterSuite', () => scenario.suiteTeardown(suite)]);
github mozilla-b2g / gaia / tests / jsmarionette / runner / marionette-js-runner / lib / ui.js View on Github external
context.suite.skip = function(title, fn) {
      var suite = Suite.create(suites[0], title);
      suite.pending = true;
      suites.unshift(suite);
      fn.call(suite);
      suites.shift();
    };
github pact-foundation / pact-js / pact-mocha-interface / src / index.js View on Github external
context.xPact = function (consumer, provider, fn) {
      var pactSuite = Suite.create(suites[0], `Pact ${consumer} <=> ${provider}`)
      pactSuite.pending = true
      suites.unshift(pactSuite)
      fn.call(pactSuite, {})
      suites.shift()
    }
github iensu / mocha-cakes-2 / mocha-cakes.js View on Github external
function wrapper(title, fn) {
      var suite = Suite.create(suites[0], createLabel(title));

      suite.file = file;
      suites.unshift(suite);
      fn.call(suite);
      suites.shift();

      applyRegisteredHooks(suite, type);

      return suite;
    }
github pact-foundation / pact-js-mocha / src / index.js View on Github external
context.xPact = context.xPactProvider = function (consumer, provider, fn) {
      var pactSuite = Suite.create(suites[0], consumer + ' has pact with ' + provider)
      pactSuite.pending = true
      suites.unshift(pactSuite)
      fn.call(pactSuite, {})
      suites.shift()
    }
github pact-foundation / pact-js / src / mocha / index.js View on Github external
context.describe = context.context = function (title, fn) {
      var suite = Suite.create(suites[0], title)
      suite.file = file
      suites.unshift(suite)
      fn.call(suite)
      suites.shift()
      return suite
    }
github pact-foundation / pact-js-mocha / src / index.js View on Github external
context.PactProvider = function (opts, fn) {
      var pactSuite = Suite.create(suites[0], opts.consumer + ' has pact with ' + opts.provider)
      pactSuite.file = file

      pactSuite.pactConsumer = opts.consumer
      pactSuite.pactProvider = opts.provider

      suites.unshift(pactSuite)
      fn.call(pactSuite, {})
      suites.shift()

      return pactSuite
    }