2021-04-19 02:16:31 -07:00
|
|
|
require("dotenv").config();
|
2021-04-16 03:04:39 -07:00
|
|
|
const { initPlugin } = require("cypress-plugin-snapshots/plugin");
|
2021-02-04 22:19:10 -08:00
|
|
|
|
|
|
|
module.exports = (on, config) => {
|
2021-04-16 03:04:39 -07:00
|
|
|
initPlugin(on, config);
|
2021-04-19 02:16:31 -07:00
|
|
|
|
2021-05-04 13:15:27 -07:00
|
|
|
ensureWindowSize(on);
|
|
|
|
|
2021-04-19 02:16:31 -07:00
|
|
|
config.env.AUTH0_TEST_CLIENT_ID = process.env.AUTH0_TEST_CLIENT_ID;
|
|
|
|
config.env.AUTH0_TEST_CLIENT_SECRET = process.env.AUTH0_TEST_CLIENT_SECRET;
|
|
|
|
config.env.DTI_TEST_USER_PASSWORD = process.env.DTI_TEST_USER_PASSWORD;
|
|
|
|
|
2021-04-16 03:04:39 -07:00
|
|
|
return config;
|
|
|
|
};
|
2021-05-04 13:15:27 -07:00
|
|
|
|
|
|
|
// Our screenshots from `cypress-plugin-snapshots` are affected by the actual
|
|
|
|
// window size, not just the viewport size! To avoid downscaling outfit
|
|
|
|
// previews, try to open the window at 1000x800 at minimum.
|
2021-05-04 13:49:53 -07:00
|
|
|
//
|
|
|
|
// Adapted from https://github.com/meinaart/cypress-plugin-snapshots/issues/104#issuecomment-636463370
|
2021-05-04 13:15:27 -07:00
|
|
|
function ensureWindowSize(on) {
|
|
|
|
const w = 1000;
|
|
|
|
const h = 800;
|
|
|
|
|
|
|
|
on("before:browser:launch", (browser = {}, launchOptions) => {
|
|
|
|
switch (browser.name) {
|
|
|
|
case "chrome":
|
|
|
|
launchOptions.args.push(`--window-size=${w},${h}`);
|
|
|
|
break;
|
|
|
|
case "electron":
|
|
|
|
launchOptions.preferences.width = w;
|
|
|
|
launchOptions.preferences.height = h;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.warn(
|
|
|
|
`[ensureWindowSize] Browser engine ${browser.name} not recognized`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return launchOptions;
|
|
|
|
});
|
|
|
|
}
|