* Fix type definitions * Fix typo * Added support for fetch() within tests
This commit is contained in:
@@ -3,7 +3,7 @@ const BlinkDiff = require('blink-diff');
|
||||
const { resolve } = require('path');
|
||||
|
||||
// @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 threshold = config.threshold || 0.001; // @todo use `??`
|
||||
|
||||
@@ -46,4 +46,4 @@ const compareSceenshots = async ({ config, screenshotsFolder, specName }) => {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = compareSceenshots;
|
||||
module.exports = compareScreenshots;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
interface CompareSceenshotsConfig {
|
||||
interface CompareScreenshotsConfig {
|
||||
name: string;
|
||||
threshold?: number;
|
||||
}
|
||||
|
||||
Cypress.Commands.add('compareSceenshots', (config: CompareSceenshotsConfig | string) => {
|
||||
cy.task('compareSceenshots', {
|
||||
Cypress.Commands.add('compareScreenshots', (config: CompareScreenshotsConfig | string) => {
|
||||
cy.task('compareScreenshots', {
|
||||
config,
|
||||
screenshotsFolder: Cypress.config('screenshotsFolder'),
|
||||
specName: Cypress.spec.name,
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
declare namespace Cypress {
|
||||
interface Chainable {
|
||||
compareSnapshot(args: CompareSnapshotArgs): void;
|
||||
compareScreenshots(config: CompareScreenshotsConfig | string): Chainable;
|
||||
logToConsole(message: string, optional?: any): void;
|
||||
readProvisions(filePaths: string[]): Chainable;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
// Cypress.on('uncaught:exception', (err, runnable) => {
|
||||
// // returning false here prevents Cypress from
|
||||
|
||||
Reference in New Issue
Block a user