Gathering detailed insights and metrics for @swimlane/cy-dom-diff
Gathering detailed insights and metrics for @swimlane/cy-dom-diff
Gathering detailed insights and metrics for @swimlane/cy-dom-diff
Gathering detailed insights and metrics for @swimlane/cy-dom-diff
Allows matching chunks of DOM against HTML; including dynamic content.
npm install @swimlane/cy-dom-diff
Typescript
Module System
Node Version
NPM Version
TypeScript (66.19%)
JavaScript (27.81%)
HTML (6%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
9 Stars
45 Commits
1 Forks
3 Watchers
1 Branches
7 Contributors
Updated on Mar 15, 2022
Latest Version
2.0.0
Package Id
@swimlane/cy-dom-diff@2.0.0
Size
4.55 kB
NPM Version
6.13.4
Node Version
12.15.0
Published on
Feb 02, 2021
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
1
20
cy-dom-diff
allows matching chunks of DOM against HTML; including dynamic content.
cy-dom-diff
consist of two parts. First is a Cypress command that matches a DOM element against a regular expression. When a DOM element is matched its HTML is normalized to produce consistent diffable output while maintaining sematic meaning. This includes:
In the second part cy-dom-diff
provides a template function to generate a regular expression from a HTML string. This HTML string is passed through the same normalization as the DOM element (described above) as well as allowing embedded regular expression for dynamic content.
1npm install --save-dev @swimlane/cy-dom-diff
Import the Cypress commands in cypress/support/index.js
or cypress/support/commands.js
1import '@swimlane/cy-dom-diff/commands';
In a basic example the following will assert that the element matches the regexp generated by the dom
template tag. Most of the HTML string within the tagged template string is treated literally. However, regular expressions within the embedded expression are matches as expected.
1import { dom } from '@swimlane/cy-dom-diff'; 2 3const TIME = /\d?\d:\d?\d\:\d?\d/; 4const NUMBER = /[\+\-]?\d*\.?\d+(?:[Ee][\+\-]?\d+)?/; 5 6cy.get('#clock').domMatch(dom` 7 <span>The current time is:</span> 8 <span class="clock">${TIME} ${/[AP]/}M</span> 9 <span class="offset">${NUMBER}</span> hrs 10 `);
cy.domMatch
Cypress commandcy.domMatch
will run the domMatch
assertions (see below) and add a Cypress runner log with a diff.
cy.domDiff
Cypress commandcy.domDiff
is used in the same way as cy.domMatch
but will only add a Cypress runner log with a diff. It will not fail if the DOM does not match and will not retry.
domMatch
Chai assertionAt its lowest level cy-dom-diff
adds a Chai assertion for matching the DOM. This will not generate a Cypress log except to show that the assertion passed or failed. Use cy.domMatch
to get better logging.
1import { dom } from '@swimlane/cy-dom-diff'; 2 3const TIME = /\d?\d:\d?\d\:\d?\d/; 4const NUMBER = /[\+\-]?\d*\.?\d+(?:[Ee][\+\-]?\d+)?/; 5 6cy.get('#clock').should('domMatch', dom` 7 <span>The current time is:</span> 8 <span class="clock">${TIME} ${/[AP]/}M</span> 9 <span class="offset">${NUMBER}</span> hrs 10`); 11 12// OR 13 14cy.get('#clock').then($el => { 15 expect($el).to.domMatch(dom` 16 <span>The current time is:</span> 17 <span class="clock">${TIME} ${/[AP]/}M</span> 18 <span class="offset">${NUMBER}</span> hrs 19 `); 20});
cy-dom-diff
is a Swimlane open-source project; we believe in giving back to the open-source community by sharing some of the projects we build for our application. Swimlane is an automated cyber security operations and incident response platform that enables cyber security teams to leverage threat intelligence, speed up incident response and automate security operations.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
Found 0/21 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
33 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More