Skip to content

A Cypress custom command to set window.devicePixelRatio

Notifications You must be signed in to change notification settings

Popmenu/cypress-set-device-pixel-ratio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Cypress custom command to set window.devicePixelRatio by adjusting Emulation.setDeviceMetricsOverride.

Installation

npm install --save-dev cypress-set-device-pixel-ratio
# or
yarn add --dev cypress-set-device-pixel-ratio

Typescript

In your tsconfig.json file, add the package to the types array:

{
  "compilerOptions": {
    "types": ["cypress", "cypress-set-device-pixel-ratio", "node"],
  },
}

Usage

  1. In your Cypress commands.js file, import the package:
import 'cypress-set-device-pixel-ratio';
  1. Use the cy.setDevicePixelRatio() command in your Cypress tests:
describe('Test suite', () => {
  it('Test case', () => {
    cy.setDevicePixelRatio(2);
    // Or
    cy.setDevicePixelRatio(2, {
      mobile: true;
      width: 375;
      height: 667;
    });
    // your test steps
  });
});

About

A Cypress custom command to set window.devicePixelRatio

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published