Sha256: e202a200c85db09f35276083640288901a1cababfb3f0d68589abc5fd215887e

Contents?: true

Size: 1.87 KB

Versions: 21

Compression:

Stored size: 1.87 KB

Contents

/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
 * @type {Cypress.PluginConfig}
 */
// eslint-disable-next-line no-unused-vars
const path = require("path");

const webpack = require("@cypress/webpack-preprocessor");
const {
  cypressBrowserPermissionsPlugin,
} = require("cypress-browser-permissions");
const fs = require("fs-extra");

const getConfigurationByFile = file => {
  const pathToConfigFile = `config/cypress.${file}.json`;

  return file && fs.readJsonSync(path.join(__dirname, "../", pathToConfigFile));
};

const merge = (target, source = {}) => {
  Object.keys(source).forEach(key => {
    if (source[key] && typeof source[key] === "object") {
      merge((target[key] = target[key] || {}), source[key]);

      return;
    }
    target[key] = source[key];
  });

  return target;
};

module.exports = (on, config) => {
  const environment = config.env.configFile;
  const configForEnvironment = getConfigurationByFile(environment);
  const options = {
    // send in the options from your webpack.config.js
    webpackOptions: require("../webpack.config"),
    watchOptions: {},
  };
  on("file:preprocessor", webpack(options));

  config = cypressBrowserPermissionsPlugin(on, config);

  const newEnvironment = merge(config, configForEnvironment);
  require("@cypress/grep/src/plugin")(newEnvironment);
  require("@cypress/code-coverage/task")(on, newEnvironment);

  return config, newEnvironment;
};

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
neeto-commons-backend-1.0.89 lib/neeto_commons_backend/common_files/cypress-tests/cypress/plugins/index.js