
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
CSS Style assertions for elements, using Chai.js. All assertions is builtin using window.getComputedStyle
method.
npm install --save-dev chai-style
// in your spec, set the plugin in chai
const {expect} = require('chai')
.use(require('chai-style'))
Use method .style
to inspect style of a element, e.g.
const element = document.querySelector('h2')
expect(element).to.have.style('color', 'red')
Properties can be defined in camel case or separated by hifen, like in css
expect(element).to.have.style('backgroundColor')
// or
expect(element).to.have.style('background-color')
To assert a value just pass a second argument to method style, like below
// assert if element has property display with value black
expect(element).to.have.style('display', 'block')
Some browsers can generate a differente value to color, like 'red' or 'rgb(255, 0, 0)'. Whatever, this assertion supports named colors, rgb, rgba, hexadecimal, and hsl
element.style.color = '#f00'
expect(element).to.have.style('color', 'red') // asserts colors indiferrent of value used
To assert unit values, use like css
element.style.height = '50vh'
expect(element).to.have.style('height', '50vh')
// too works if you assert with respective value in pixels
expect(element).to.have.style('height', '323px') // 323 is the half of viewport in this case, equals to 50vh
Actually, the css units supported is
Other units will come soon. Pull requests be welcome!
FAQs
CSS Style assertions for elements, using Chai.js
The npm package chai-style receives a total of 281 weekly downloads. As such, chai-style popularity was classified as not popular.
We found that chai-style 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
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.