Last active
January 5, 2022 08:15
-
-
Save dminkovski/407a39249ca78a0ceab7d767f97816e5 to your computer and use it in GitHub Desktop.
cypress/plugins/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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 browserify = require('@cypress/browserify-preprocessor'); | |
const cucumber = require('cypress-cucumber-preprocessor').default; | |
const resolve = require('resolve'); | |
const { initPlugin } = require('cypress-plugin-snapshots/plugin'); | |
module.exports = (on, config) => { | |
// `on` is used to hook into various events Cypress emits | |
// `config` is the resolved Cypress config | |
require('@cypress/code-coverage/task')(on, config); | |
on('file:preprocessor', require('@cypress/code-coverage/use-babelrc')); | |
const options = { | |
...browserify.defaultOptions, | |
typescript: resolve.sync('typescript', { baseDir: './app' }), | |
}; | |
on('file:preprocessor', cucumber(options)); | |
initPlugin(on, config); | |
on('before:browser:launch', (browser, launchOptions) => { | |
if (browser.name === 'chrome') { | |
launchOptions.args.push('--window-size=1920,1080'); | |
return launchOptions; | |
} | |
if (browser.name === 'firefox') { | |
launchOptions.args.push('--width=1920'); | |
launchOptions.args.push('--height=1080'); | |
return launchOptions; | |
} | |
if (browser.name === 'electron') { | |
launchOptions.args['width'] = 1920; | |
launchOptions.args['height'] = 1080; | |
launchOptions.args['resizable'] = false; | |
return launchOptions; | |
} | |
}); | |
return config; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment