Commit df7647b2 by Steven Vachon Committed by GitHub

@grafana/e2e: improvements and dumb fixes for #25203 (#25269)

* Fix type definitions

* Fix typo

* Added support for fetch() within tests
parent 376a9d35
...@@ -3,7 +3,7 @@ const BlinkDiff = require('blink-diff'); ...@@ -3,7 +3,7 @@ const BlinkDiff = require('blink-diff');
const { resolve } = require('path'); const { resolve } = require('path');
// @todo use npmjs.com/pixelmatch or an available cypress plugin // @todo use npmjs.com/pixelmatch or an available cypress plugin
const compareSceenshots = async ({ config, screenshotsFolder, specName }) => { const compareScreenshots = async ({ config, screenshotsFolder, specName }) => {
const name = config.name || config; // @todo use `??` const name = config.name || config; // @todo use `??`
const threshold = config.threshold || 0.001; // @todo use `??` const threshold = config.threshold || 0.001; // @todo use `??`
...@@ -46,4 +46,4 @@ const compareSceenshots = async ({ config, screenshotsFolder, specName }) => { ...@@ -46,4 +46,4 @@ const compareSceenshots = async ({ config, screenshotsFolder, specName }) => {
} }
}; };
module.exports = compareSceenshots; module.exports = compareScreenshots;
interface CompareSceenshotsConfig { interface CompareScreenshotsConfig {
name: string; name: string;
threshold?: number; threshold?: number;
} }
Cypress.Commands.add('compareSceenshots', (config: CompareSceenshotsConfig | string) => { Cypress.Commands.add('compareScreenshots', (config: CompareScreenshotsConfig | string) => {
cy.task('compareSceenshots', { cy.task('compareScreenshots', {
config, config,
screenshotsFolder: Cypress.config('screenshotsFolder'), screenshotsFolder: Cypress.config('screenshotsFolder'),
specName: Cypress.spec.name, specName: Cypress.spec.name,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
declare namespace Cypress { declare namespace Cypress {
interface Chainable { interface Chainable {
compareSnapshot(args: CompareSnapshotArgs): void; compareScreenshots(config: CompareScreenshotsConfig | string): Chainable;
logToConsole(message: string, optional?: any): void; logToConsole(message: string, optional?: any): void;
readProvisions(filePaths: string[]): Chainable; readProvisions(filePaths: string[]): Chainable;
} }
......
...@@ -24,6 +24,12 @@ if (Cypress.env('SLOWMO')) { ...@@ -24,6 +24,12 @@ if (Cypress.env('SLOWMO')) {
} }
} }
// @todo remove when possible: https://github.com/cypress-io/cypress/issues/95
Cypress.on('window:before:load', win => {
// @ts-ignore
delete win.fetch;
});
// uncomment below to prevent Cypress from failing tests when unhandled errors are thrown // uncomment below to prevent Cypress from failing tests when unhandled errors are thrown
// Cypress.on('uncaught:exception', (err, runnable) => { // Cypress.on('uncaught:exception', (err, runnable) => {
// // returning false here prevents Cypress from // // returning false here prevents Cypress from
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment