Closed siluo closed 5 years ago
The existing cypress/plugins/index.js file:
/* eslint-disable no-console */ const browserify = require('@cypress/browserify-preprocessor'); const path = require('path'); const fs = require('fs'); const { get, merge } = require('lodash'); // *********************************************************** // 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) module.exports = (on, config) => { let customBrowserify; on('before:browser:launch', (browser = {}) => { const options = browserify.defaultOptions; const envPreset = options.browserifyOptions.transform[1][1].presets[0]; options.browserifyOptions.transform[1][1].presets[0] = [ envPreset, { ignoreBrowserslistConfig: true, targets: { [browser.name]: browser.majorVersion } }, ]; customBrowserify = browserify(options); }); on('file:preprocessor', file => customBrowserify(file)); const env = get(config, ['env', 'ourEnv'], 'local'); let newConfig = config; const envConfigPath = path.resolve(__dirname, '../config/', `${env}.json`); if (fs.existsSync(envConfigPath)) { // eslint-disable-next-line global-require,import/no-dynamic-require const envConfig = require(envConfigPath); console.log(`Using ${env} env config:`, JSON.stringify(envConfig, null, 2)); newConfig = merge(config, envConfig); } else { console.error('ERROR: Could not find config file:', envConfigPath); } console.log('CONFIG:', JSON.stringify(newConfig, null, 2)); return newConfig; };
How should i construct the above with the mocha-like selection:
const selectTestsWithGrep = require('../../grep') module.exports = (on, config) => { on('file:preprocessor', selectTestsWithGrep(config)) }
:tada: This issue has been resolved in version 1.4.0 :tada:
The release is available on:
npm package (@latest dist-tag)
Your semantic-release bot :package::rocket:
The existing cypress/plugins/index.js file:
How should i construct the above with the mocha-like selection: