Skip to content
Snippets Groups Projects
Unverified Commit 0fea0879 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

[Cypress runner] Set `HAS_ENTERPRISE_TOKEN` using Configuration API (#17006) (#17016)

* Set `HAS_ENTERPRISE_TOKEN` using Cypress Configuration and Plugins API

* Re-organize webpack preprocessor options
parent 90435d6d
Branches
Tags
No related merge requests found
......@@ -90,11 +90,6 @@ const init = async () => {
// See: https://docs.cypress.io/guides/references/configuration#Command-Line
const commandLineConfig = JSON.stringify(config);
// These env vars provide the token to the backend.
// If they're not present, we skip some tests that depend on a valid token.
const hasEnterpriseToken =
process.env["ENTERPRISE_TOKEN"] && process.env["MB_EDITION"] === "ee";
const cypressProcess = spawn(
"yarn",
[
......@@ -112,7 +107,6 @@ const init = async () => {
"mochaFile=cypress/results/results-[hash].xml",
]
: []),
...(hasEnterpriseToken ? ["--env", "HAS_ENTERPRISE_TOKEN=true"] : []),
],
{ stdio: "inherit" },
);
......
// ***********************************************************
// This example plugins/index.js can be used to load plugins
// This file can be used to load plugins and to register events.
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
......@@ -8,9 +8,24 @@
// https://on.cypress.io/plugins-guide
// ***********************************************************
/**
* This env var provides the token to the backend.
* If it is not present, we skip some tests that depend on a valid token.
*
* @type {boolean}
*/
const hasEnterpriseToken =
process.env["ENTERPRISE_TOKEN"] && process.env["MB_EDITION"] === "ee";
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const webpack = require("@cypress/webpack-preprocessor");
const { resolve } = require("../../../../webpack.config.js");
const webpackPluginOptions = {
webpackOptions: { resolve },
watchOptions: {},
};
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
......@@ -19,13 +34,8 @@ module.exports = (on, config) => {
/********************************************************************
** WEBPACK **
********************************************************************/
const { resolve } = require("../../../../webpack.config.js");
const options = {
webpackOptions: { resolve },
watchOptions: {},
};
on("file:preprocessor", webpack(options));
on("file:preprocessor", webpack(webpackPluginOptions));
/********************************************************************
** BROWSERS **
......@@ -39,4 +49,12 @@ module.exports = (on, config) => {
return launchOptions;
}
});
/********************************************************************
** CONFIG **
********************************************************************/
config.env.HAS_ENTERPRISE_TOKEN = hasEnterpriseToken;
return config;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment