Cypress hint to ensure minimum window size
Lol this is mostly to stop me from accidentally launching it too small 😅
also there seemed to be subtle pixel shifts from some of this? idk still flakier than I want I guess, but hopefully it sticks a bit better now with the new window size hints…
This commit is contained in:
parent
8bd64f7aae
commit
93bc960221
3 changed files with 27 additions and 0 deletions
Binary file not shown.
Before Width: | Height: | Size: 363 KiB After Width: | Height: | Size: 364 KiB |
Binary file not shown.
Before Width: | Height: | Size: 398 KiB After Width: | Height: | Size: 398 KiB |
|
@ -4,9 +4,36 @@ const { initPlugin } = require("cypress-plugin-snapshots/plugin");
|
||||||
module.exports = (on, config) => {
|
module.exports = (on, config) => {
|
||||||
initPlugin(on, config);
|
initPlugin(on, config);
|
||||||
|
|
||||||
|
ensureWindowSize(on);
|
||||||
|
|
||||||
config.env.AUTH0_TEST_CLIENT_ID = process.env.AUTH0_TEST_CLIENT_ID;
|
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.AUTH0_TEST_CLIENT_SECRET = process.env.AUTH0_TEST_CLIENT_SECRET;
|
||||||
config.env.DTI_TEST_USER_PASSWORD = process.env.DTI_TEST_USER_PASSWORD;
|
config.env.DTI_TEST_USER_PASSWORD = process.env.DTI_TEST_USER_PASSWORD;
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue