Skip to content

Commit

Permalink
icon test command remove scrollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Šimon Macek committed Jun 27, 2024
1 parent 2e155ff commit 4c17941
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,20 @@ Cypress.Commands.add('waitForStylesheets', () => {
* });
*/
Cypress.Commands.add('testIcon', ({ element, name, size }) => {
cy.wrap(element[0]).should('be.visible');
// timestamp for matching see https://docs.cypress.io/guides/tooling/visual-testing#Timestamps
const now = new Date(2024, 1, 1);
cy.clock(now);
// set DPR and wait for resources (to avoid empty snapshot)
cy.setDPR(1);
cy.waitForFonts();
cy.waitForStylesheets();
// remove scrollbar
cy.wrap(element[0]).invoke('attr', 'style', 'overflow: hidden');
// size
cy.wrap(element[0]).invoke('width').should('eq', size);
cy.wrap(element[0]).invoke('height').should('eq', size);
// snapshot
cy.wrap(element[0]).should('be.visible');
cy.wrap(element[0]).matchImageSnapshot(name, {
failureThreshold: 0.1,
failureThresholdType: 'percent',
Expand Down

0 comments on commit 4c17941

Please sign in to comment.