2018-08-03 19:23:43 -04:00
|
|
|
// ***********************************************************
|
|
|
|
// 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)
|
2019-09-03 21:56:20 +03:00
|
|
|
require('dotenv').config();
|
2019-10-22 19:59:13 +03:00
|
|
|
const { setupGitHub, teardownGitHub, setupGitHubTest, teardownGitHubTest } = require('./github');
|
|
|
|
const { copyBackendFiles } = require('../utils/config');
|
2019-09-03 21:56:20 +03:00
|
|
|
|
|
|
|
module.exports = async on => {
|
|
|
|
// `on` is used to hook into various events Cypress emits
|
|
|
|
on('task', {
|
2019-10-22 19:59:13 +03:00
|
|
|
async setupBackend({ backend, options }) {
|
2019-09-03 21:56:20 +03:00
|
|
|
console.log('Preparing environment for backend', backend);
|
|
|
|
await copyBackendFiles(backend);
|
|
|
|
|
2019-10-22 19:59:13 +03:00
|
|
|
let result = null;
|
2019-09-03 21:56:20 +03:00
|
|
|
if (backend === 'github') {
|
2019-10-22 19:59:13 +03:00
|
|
|
result = await setupGitHub(options);
|
2019-09-03 21:56:20 +03:00
|
|
|
}
|
|
|
|
|
2019-10-22 19:59:13 +03:00
|
|
|
return result;
|
2019-09-03 21:56:20 +03:00
|
|
|
},
|
|
|
|
async teardownBackend(taskData) {
|
|
|
|
const { backend } = taskData;
|
|
|
|
console.log('Tearing down backend', backend);
|
2019-10-22 19:59:13 +03:00
|
|
|
|
2019-09-03 21:56:20 +03:00
|
|
|
if (backend === 'github') {
|
2019-10-22 19:59:13 +03:00
|
|
|
await teardownGitHub(taskData);
|
2019-09-03 21:56:20 +03:00
|
|
|
}
|
|
|
|
|
2019-10-22 19:59:13 +03:00
|
|
|
console.log('Restoring defaults');
|
|
|
|
await copyBackendFiles('test');
|
|
|
|
|
2019-09-03 21:56:20 +03:00
|
|
|
return null;
|
|
|
|
},
|
2019-10-22 19:59:13 +03:00
|
|
|
async setupBackendTest(taskData) {
|
|
|
|
const { backend, testName } = taskData;
|
|
|
|
console.log(`Setting up single test '${testName}' for backend`, backend);
|
|
|
|
|
2019-09-03 21:56:20 +03:00
|
|
|
if (backend === 'github') {
|
2019-10-22 19:59:13 +03:00
|
|
|
await setupGitHubTest(taskData);
|
2019-09-03 21:56:20 +03:00
|
|
|
}
|
2019-10-22 19:59:13 +03:00
|
|
|
|
|
|
|
return null;
|
2019-09-03 21:56:20 +03:00
|
|
|
},
|
2019-10-22 19:59:13 +03:00
|
|
|
async teardownBackendTest(taskData) {
|
|
|
|
const { backend, testName } = taskData;
|
|
|
|
|
|
|
|
console.log(`Tearing down single test '${testName}' for backend`, backend);
|
|
|
|
|
2019-09-03 21:56:20 +03:00
|
|
|
if (backend === 'github') {
|
2019-10-22 19:59:13 +03:00
|
|
|
await teardownGitHubTest(taskData);
|
2019-09-03 21:56:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
});
|
2019-10-22 19:59:13 +03:00
|
|
|
|
|
|
|
// to allows usage of a mock proxy
|
|
|
|
on('before:browser:launch', (browser = {}, args) => {
|
|
|
|
if (browser.name === 'chrome') {
|
|
|
|
args.push('--ignore-certificate-errors');
|
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (browser.name === 'electron') {
|
|
|
|
args['ignore-certificate-errors'] = true;
|
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
});
|
2019-09-03 21:56:20 +03:00
|
|
|
};
|