Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@porsche-design-system/visual-regression-tester
Advanced tools
Export functions to create visual regression tests.
Export functions to create visual regression tests.
Run the following command using npm:
npm install @porsche-design-system/visual-regression-tester --save-dev
If you prefer Yarn, use the following command instead:
yarn add @porsche-design-system/visual-regression-tester --dev
It's highly recommended executing the visual regression tester within a Docker container to get reliable tests results across any operating system and machine.
Check out the Basic integration example for an example how to get the Visual Regression Tester up and running.
The constructor expects two parameters:
browser: Browser
options: VisualRegressionTestOptions
(optional)Browser should be a Puppeteer Browser instance. Check the basic integration example for how to create a Puppeteer browser.
In the actual visual regression test you have to call
the test(snapshotId: string, scenario: Function, options: TestOptions = {elementSelector: '', maskSelectors: [], regressionSuffix: ''})
-method in your expect block, taken a unique name of the reference shot as first parameter (snapshotId: string
).
As second parameter (scenario: Function
) within the scenario callback function you call the goTo()
method with
the extended URL (will be concatinated with the baseURL
), as well as click()
, hover()
, focus()
and type()
if
necessary and prepare the state to compare.
goTo()
, click()
, hover()
, focus()
and type()
method accept following optional
parameters networkIdleTimeout: number
and maxInflightRequests: number
which means, — consider loading has finished
when there are no more than maxInflightRequests
network connections for at least networkIdleTimeout
ms.
As a third and optional parameter (options: TestOptions
) you can pass following options:
elementSelector: string = ''
- pass a css selector for the element (selector is allowed to match exactly one element
only) that should be included in your visual regression test.maskSelectors: string[] = []
- pass a string array which includes css selectors for the elements that should be
ignored in your visual regression test. If maskSelectors
is used in combination with elementSelector
then those
two selectors are concatenated automatically to match elements nested in elementSelector
.regressionSuffix: string = ''
- pass a string to add a suffix in regression filenamesTo make use of Puppeteers Page instance within the scenario: Function
you call the getPage()
method and apply any
supported Puppeteer method like click()
, hover()
or type()
.
viewports
selects the viewports of your browserdeviceScaleFactor
specify device scale factor (can be thought of as dpr)fixturesDir
directory where the reference-shots will be savedresultsDir
directory where the diffing- and the regression-shots will be savedtolerance
gives the tolerance range for your visual regression diffsbaseUrl
the base URL of the page you would like to testtimeout
impacts the timeout limit of page loadmode
defines the method with which the height for snapshot is determinedNote: All the VisualRegressionTestOptions are optional, those are the default options:
viewports: [320, 480, 760, 1000, 1300, 1760]
deviceScaleFactor: 1
fixturesDir: 'vrt/fixtures'
resultsDir: 'vrt/results'
tolerance: 0
baseUrl: 'http://localhost'
timeout: 30000
mode: 'auto'
resultsDir
folder to .gitignore
in order to not spam git history.resultsDir
directory. Here you can find the belonging diff
and regression
images.fixturesDir
folder with the belonging one in the resultsDir
folder
and delete the images in the resultsDir
directory afterwards manually.FAQs
Export functions to create visual regression tests.
The npm package @porsche-design-system/visual-regression-tester receives a total of 7 weekly downloads. As such, @porsche-design-system/visual-regression-tester popularity was classified as not popular.
We found that @porsche-design-system/visual-regression-tester demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.