sigwinhq / infra

Sigwin's default per-project infra
3 stars 0 forks source link

feat: Support for adding attributes to an element before visual testing #68

Closed brankol closed 1 year ago

brankol commented 1 year ago

Usage

In a visual test scenario add: addAttribute: {selector: 'body', attribute: {name: 'class', value: 'my-class'}}

Adding more than one attribute is possible by using an array:

addAttributes: [
    {selector: '#root', attribute: {name: 'class', value: 'bg-yellow}},
    {selector: 'body', attribute: {name: 'class', value: 'bg-red'}},
],

If the attribute already exists, the new value will be appended to the existing value with space as the delimiter. In case a different delimiter is necessary, it's possible to change it by adding a delimiter property. Example: addAttribute: {selector: 'body', attribute: {name: 'data-controller', value: 'another'}, delimiter: ', ' }