Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@swimlane/cy-dom-diff
Advanced tools
Changelog
2.0.0 (2021-02-02)
Readme
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.
npm install --save-dev @swimlane/cy-dom-diff
Import the Cypress commands in cypress/support/index.js
or cypress/support/commands.js
import '@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.
import { dom } from '@swimlane/cy-dom-diff';
const TIME = /\d?\d:\d?\d\:\d?\d/;
const NUMBER = /[\+\-]?\d*\.?\d+(?:[Ee][\+\-]?\d+)?/;
cy.get('#clock').domMatch(dom`
<span>The current time is:</span>
<span class="clock">${TIME} ${/[AP]/}M</span>
<span class="offset">${NUMBER}</span> hrs
`);
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.
import { dom } from '@swimlane/cy-dom-diff';
const TIME = /\d?\d:\d?\d\:\d?\d/;
const NUMBER = /[\+\-]?\d*\.?\d+(?:[Ee][\+\-]?\d+)?/;
cy.get('#clock').should('domMatch', dom`
<span>The current time is:</span>
<span class="clock">${TIME} ${/[AP]/}M</span>
<span class="offset">${NUMBER}</span> hrs
`);
// OR
cy.get('#clock').then($el => {
expect($el).to.domMatch(dom`
<span>The current time is:</span>
<span class="clock">${TIME} ${/[AP]/}M</span>
<span class="offset">${NUMBER}</span> hrs
`);
});
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.
FAQs
matching chunks of DOM against HTML; including dynamic content.
The npm package @swimlane/cy-dom-diff receives a total of 548 weekly downloads. As such, @swimlane/cy-dom-diff popularity was classified as not popular.
We found that @swimlane/cy-dom-diff demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 40 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.