{"id":14989793,"url":"https://github.com/darlanmendonca/chai-style","last_synced_at":"2025-04-12T01:41:01.433Z","repository":{"id":57196639,"uuid":"90152899","full_name":"darlanmendonca/chai-style","owner":"darlanmendonca","description":"CSS Style assertions for elements, using Chai.js","archived":false,"fork":false,"pushed_at":"2017-11-16T13:20:20.000Z","size":85,"stargazers_count":4,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T21:21:56.210Z","etag":null,"topics":["assertions","chai","css","integration-test","test","unit-test"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/darlanmendonca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-03T13:36:49.000Z","updated_at":"2020-06-22T14:39:03.000Z","dependencies_parsed_at":"2022-09-01T05:54:09.845Z","dependency_job_id":null,"html_url":"https://github.com/darlanmendonca/chai-style","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darlanmendonca%2Fchai-style","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darlanmendonca%2Fchai-style/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darlanmendonca%2Fchai-style/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darlanmendonca%2Fchai-style/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darlanmendonca","download_url":"https://codeload.github.com/darlanmendonca/chai-style/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501922,"owners_count":21114681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertions","chai","css","integration-test","test","unit-test"],"created_at":"2024-09-24T14:18:55.303Z","updated_at":"2025-04-12T01:41:01.409Z","avatar_url":"https://github.com/darlanmendonca.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/darlanmendonca/chai-style.svg?branch=master)](https://travis-ci.org/darlanmendonca/chai-style)\n\u003c!-- [![Coverage Status](https://coveralls.io/repos/github/darlanmendonca/chai-style/badge.svg?branch=master)](https://coveralls.io/github/darlanmendonca/chai-style?branch=master) --\u003e\n\n# chai-style\n\nCSS Style assertions for elements, using [Chai.js](http://chaijs.com/). All assertions is builtin using `window.getComputedStyle` method.\n\n## Install\n\n```sh\nnpm install --save-dev chai-style\n```\n\n```js\n// in your spec, set the plugin in chai\nconst {expect} = require('chai')\n  .use(require('chai-style'))\n```\n\n## Style as chainable assertion\n\nUse method `.style` to inspect style of a element, e.g.\n\n```js\nconst element = document.querySelector('h2')\nexpect(element).to.have.style('color', 'red')\n```\n\nProperties can be defined in camel case or separated by hifen, like in css\n\n```js\nexpect(element).to.have.style('backgroundColor')\n// or\nexpect(element).to.have.style('background-color')\n```\n\n### Values\n\nTo assert a value just pass a second argument to method style, like below\n\n```js\n// assert if element has property display with value black\nexpect(element).to.have.style('display', 'block')\n```\n\n### Colors\n\nSome browsers can generate a differente value to color, like 'red' or 'rgb(255, 0, 0)'.\nWhatever, this assertion supports named colors, rgb, rgba, hexadecimal, and hsl\n\n```js\nelement.style.color = '#f00'\nexpect(element).to.have.style('color', 'red') // asserts colors indiferrent of value used\n```\n\n\n### Units\n\nTo assert unit values, use like css\n\n```js\nelement.style.height = '50vh'\nexpect(element).to.have.style('height', '50vh')\n// too works if you assert with respective value in pixels\nexpect(element).to.have.style('height', '323px') // 323 is the half of viewport in this case, equals to 50vh\n```\n\nActually, the css units supported is\n\n- px (pixels)\n- em (relative to element fontStyle, or inherit)\n- rem (relative to root fontStyle, the html tag)\n- vh (viewport height)\n- vw (viewport width)\n\nOther units will come soon. Pull requests be welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarlanmendonca%2Fchai-style","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarlanmendonca%2Fchai-style","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarlanmendonca%2Fchai-style/lists"}