How to use the chimp.watchTags function in chimp

To help you get started, we’ve selected a few chimp 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 TheBrainFamily / chimpy / dist / lib / jasmine / jasmine-wrapper.js View on Github external
(function () {
      // Only run specs with a watch tag in watch mode
      var watchedSpecRegExp = new RegExp((0, _environmentVariableParsers.parseString)(process.env['chimp.watchTags']).split(',').map(_escapeRegExp2.default).join('|'));
      jasmine.jasmine.addSpecFilter(function (spec) {
        return watchedSpecRegExp.test(spec.getFullName());
      });
    })();
  }
github TheBrainFamily / chimpy / dist / lib / mocha / mocha-wrapper.js View on Github external
var Mocha = require('mocha'),
    fs = require('fs'),
    path = require('path'),
    exit = require('exit'),
    glob = require('glob'),
    ui = require('./mocha-fiberized-ui');

var mochaOptions = {
  ui: 'fiberized-bdd-ui',
  timeout: process.env['chimp.mochaTimeout'],
  slow: process.env['chimp.mochaSlow'],
  reporter: process.env['chimp.mochaReporter']
};

if ((0, _environmentVariableParsers.parseBoolean)(process.env['chimp.watch'])) {
  mochaOptions.grep = new RegExp((0, _environmentVariableParsers.parseString)(process.env['chimp.watchTags']).split(',').map(_escapeRegExp2.default).join('|'));
} else {
  mochaOptions.grep = new RegExp((0, _environmentVariableParsers.parseString)(process.env['chimp.mochaTags']).split(',').map(_escapeRegExp2.default).join('|'));
}

var mocha = new Mocha(mochaOptions);

mocha.addFile(path.join(path.resolve(__dirname, path.join('mocha-helper.js'))));

if (process.argv.length > 3) {
  process.argv.splice(3).forEach(function (spec) {
    mocha.addFile(spec);
  });
} else {
  // Add each .js file to the mocha instance
  var testDir = process.env['chimp.path'];
  glob.sync(path.join(testDir, '**')).filter(function (file) {
github TheBrainFamily / chimpy / src / lib / jasmine / jasmine-wrapper.js View on Github external
const jasmine = new Jasmine();

  // Capability to add multiple spec filters
  const specFilters = [];
  jasmine.env.specFilter = function shouldRunSpec(spec) {
    return _.every(specFilters, specFilter => specFilter(spec));
  };

  jasmine.jasmine.addSpecFilter = function addSpecFilter(filterFn) {
    specFilters.push(filterFn);
  };

  if (parseBoolean(process.env['chimp.watch'])) {
    // Only run specs with a watch tag in watch mode
    const watchedSpecRegExp = new RegExp(
      parseString(process.env['chimp.watchTags']).split(',').map(escapeRegExp).join('|')
    );
    jasmine.jasmine.addSpecFilter((spec) => watchedSpecRegExp.test(spec.getFullName()));
  }

  // Capability to capture screenshots
  jasmine.jasmine.getEnv().addReporter({
    specDone: function(result) {
      if (screenshotHelper.shouldTakeScreenshot(result.status)) {
        if (booleanHelper.isTruthy(process.env['chimp.saveScreenshotsToDisk'])) {
          const affix = result.status !== 'passed' ? ' (failed)' : '';
          const fileName = result.fullName + affix;
          screenshotHelper.saveScreenshotsToDisk(fileName, projectDir);
        }
      }
    }
  });
github TheBrainFamily / chimpy / src / lib / mocha / mocha-wrapper.js View on Github external
ui = require('./mocha-fiberized-ui');

import {parseBoolean, parseNullableString, parseString} from '../environment-variable-parsers';
import escapeRegExp from '../utils/escape-reg-exp';

var mochaOptions = {
  ui: 'fiberized-bdd-ui',
  timeout: process.env['chimp.mochaTimeout'],
  slow: process.env['chimp.mochaSlow'],
  reporter: process.env['chimp.mochaReporter']
};

var mochaGrep = parseNullableString(process.env['chimp.mochaGrep']);

if (parseBoolean(process.env['chimp.watch'])) {
  mochaOptions.grep = new RegExp(parseString(process.env['chimp.watchTags']).split(',').map(escapeRegExp).join('|'));
} else if (mochaGrep) {
  mochaOptions.grep = mochaGrep;
} else {
  mochaOptions.grep = new RegExp(
    parseString(process.env['chimp.mochaTags']).split(',').map(escapeRegExp).join('|')
  );
}

var mocha = new Mocha(mochaOptions);

mocha.addFile(path.join(path.resolve(__dirname, path.join('mocha-helper.js'))));

if (process.argv.length > 3) {
  process.argv.splice(3).forEach(function (spec) {
    mocha.addFile(spec);
  });