Skip to content

Commit

Permalink
Merge pull request #53 from searchspring/patch-generate-preact-0.53.0
Browse files Browse the repository at this point in the history
adding cypress e2e.js changes for bundle interception
  • Loading branch information
dkonieczek authored Apr 1, 2024
2 parents 7fdad60 + 8683fb5 commit 7839263
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions preact/0.53.0/maintenance.preact.0.53.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ version: 0.53.0
description: 'Upgrade Cypress to 13.7.1'

steps:
# normalize set of cypress files
- run: |
cp ./patch/tests/cypress/support/e2e.js ./tests/cypress/support/e2e.js
# update Cypress dependency
- files:
package.json:
action: edit-json
Expand Down
52 changes: 52 additions & 0 deletions preact/0.53.0/tests/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// DO NOT EDIT - THIS FILE CAN/WILL BE REPLACED!!!
// ***********************************************
// Custom Snap Cypress Configuration
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************

// Import commands.js using ES2015 syntax:
import './commands';
import './custom';
import { ignoredErrors } from './custom';

// ignore 3rd party uncaught exceptions - but not bundle exceptions
Cypress.on('uncaught:exception', (err) => {
if (ignoredErrors?.length) {
for (let i = 0; i < ignoredErrors.length; i++) {
const checkFor = new RegExp(ignoredErrors[i].replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
if (err.stack.match(checkFor)) {
return false;
}
}
}

if (err.stack.match(/\/\/localhost:\d+\/bundle\./)) {
return true;
}

return false;
});

beforeEach(() => {
// make references to requests available
cy.intercept(/.*searchspring.io\/api\/search\/search/).as('search');
cy.intercept(/.*searchspring.io\/api\/search\/autocomplete/).as('autocomplete');

// prevent v2 and v3 assets
cy.intercept(/.*searchspring.net\/search\/*/, (req) => {
req.destroy();
});
cy.intercept(/.*searchspring.net\/autocomplete\/*/, (req) => {
req.destroy();
});
cy.intercept(/.*searchspring.net\/ajax_search\/js\/*/, (req) => {
req.destroy();
});

// prevent snap assets
cy.intercept(/.*snapui.searchspring.io\/.*.js.*$/, (req) => {
req.destroy();
});
});

0 comments on commit 7839263

Please sign in to comment.