2023-07-07 10:54:23 -05:00
|
|
|
/* global require __dirname */
|
2020-05-18 15:23:50 -05:00
|
|
|
var process = require('process');
|
2020-01-14 12:14:18 -06:00
|
|
|
var tasks = require('./tasks');
|
2023-05-04 07:02:18 -05:00
|
|
|
var tagify = require('cypress-tags');
|
2023-07-07 10:54:23 -05:00
|
|
|
var path = require('path');
|
|
|
|
var webpackPreprocessor = require('@cypress/webpack-preprocessor');
|
2020-01-14 11:08:51 -06:00
|
|
|
|
2020-01-14 12:14:18 -06:00
|
|
|
function plugin(on, config) {
|
2020-06-24 05:50:29 -05:00
|
|
|
if (config.env.COVERAGE_RUN)
|
|
|
|
require('@cypress/code-coverage/task')(on, config);
|
2023-04-25 10:33:38 -05:00
|
|
|
|
2020-01-14 12:14:18 -06:00
|
|
|
on('task', {
|
2020-03-13 07:47:15 -05:00
|
|
|
copyFile: tasks.copyFile,
|
2021-06-07 04:32:53 -05:00
|
|
|
getSelectors: tasks.getSelectors,
|
2020-01-14 12:14:18 -06:00
|
|
|
});
|
|
|
|
|
2020-07-30 05:42:39 -05:00
|
|
|
if (process.env.ENABLE_VIDEO_REC) {
|
|
|
|
config.video = true;
|
|
|
|
}
|
|
|
|
|
2020-07-20 06:46:15 -05:00
|
|
|
if (process.env.ENABLE_CONSOLE_LOG) {
|
|
|
|
require('cypress-log-to-output').install(on, function(type, event) {
|
|
|
|
if (event.level === 'error' || event.type === 'error') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-18 23:41:55 -05:00
|
|
|
on('before:browser:launch', function(browser, launchOptions) {
|
|
|
|
if (browser.family === 'chromium') {
|
|
|
|
if (process.env.ENABLE_LOGGING) {
|
2020-07-20 06:46:15 -05:00
|
|
|
launchOptions.args.push('--enable-logging=stderr');
|
|
|
|
launchOptions.args.push('--v=2');
|
|
|
|
}
|
2023-04-18 23:41:55 -05:00
|
|
|
launchOptions.args.push('--simulate-outdated-no-au=\'2099-12-31T23:59:59.000000+00:00\'');
|
|
|
|
}
|
|
|
|
|
|
|
|
return launchOptions;
|
|
|
|
});
|
2020-05-18 15:23:50 -05:00
|
|
|
|
2020-09-16 09:01:46 -05:00
|
|
|
if (process.env.CYPRESS_INTEGRATION === 'php-proxy') {
|
|
|
|
config.defaultCommandTimeout = 10000;
|
|
|
|
}
|
|
|
|
|
2023-07-07 10:54:23 -05:00
|
|
|
var tagsFunc = tagify.tagify(config);
|
|
|
|
var webpackFunc = webpackPreprocessor({
|
|
|
|
webpackOptions: {
|
|
|
|
resolve: {
|
|
|
|
modules:[ path.resolve(__dirname, process.env.NODE_PATH)]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
on('file:preprocessor', function(file) {
|
|
|
|
if (file.filePath.includes('integration')) {
|
|
|
|
return tagsFunc(file);
|
|
|
|
}
|
|
|
|
return webpackFunc(file);
|
|
|
|
});
|
2020-06-05 09:42:23 -05:00
|
|
|
|
2020-01-14 12:14:18 -06:00
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = plugin;
|