Confirm All HTML data- Attributes At Once By Using The dataset Property

Published: 10 April 2023
on channel: gleb bahmutov
931
31

If you have multiple "data-..." attributes on your HTML element, you can grab them all using the "dataset" property. This property has all camel-cased string values. If you want to confirm the entire set, you first convert it into a plain object and then use "deep.equal" assertion
cy.get('article#electric-cars')
.should('have.prop', 'dataset')
.then(JSON.stringify)
.then(JSON.parse)
.should('deep.include', {
columns: '3',
indexNumber: '12314',
})
This recipe is at http://glebbahmutov.com/cypress-examp...


Watch video Confirm All HTML data- Attributes At Once By Using The dataset Property online without registration, duration hours minute second in high quality. This video was added by user gleb bahmutov 10 April 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 931 once and liked it 31 people.