{"id":19701316,"url":"https://github.com/ddamato/assert-css","last_synced_at":"2026-06-14T05:33:19.228Z","repository":{"id":238888036,"uuid":"797871353","full_name":"ddamato/assert-css","owner":"ddamato","description":"Assert that CSS is constructed properly","archived":false,"fork":false,"pushed_at":"2024-05-09T22:56:16.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-06T08:56:05.263Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddamato.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-08T16:43:56.000Z","updated_at":"2024-05-09T22:56:18.000Z","dependencies_parsed_at":"2025-01-10T11:06:39.151Z","dependency_job_id":null,"html_url":"https://github.com/ddamato/assert-css","commit_stats":null,"previous_names":["ddamato/assert-css"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ddamato/assert-css","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddamato%2Fassert-css","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddamato%2Fassert-css/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddamato%2Fassert-css/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddamato%2Fassert-css/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddamato","download_url":"https://codeload.github.com/ddamato/assert-css/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddamato%2Fassert-css/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285737153,"owners_count":27223129,"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","status":"online","status_checked_at":"2025-11-22T02:00:05.934Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-11T21:08:34.768Z","updated_at":"2025-11-22T05:02:53.472Z","avatar_url":"https://github.com/ddamato.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# assert-css\n\n[![npm version](https://img.shields.io/npm/v/assert-css.svg)](https://www.npmjs.com/package/assert-css)\n\nAssert that CSS is constructed properly.\n\n## Usage\n\n```js\nimport assertCss from 'assert-css';\n\ndescribe('CSS generation', function () {\n  it('should have the expected CSS', function () {\n    assertCss('body { margin: 0; }').selector('body').includes('margin', 0);\n  });\n});\n```\n\n### Chains\n\nThe project uses object chaining to complete assertions.\n\n#### `.selector()`\n\nThe `.selector()` method has the following possible chains:\n\n- `.selector().exists()`, asserts that the selector is within the CSS.\n- `.selector().not.exists()`, asserts that the selector is not within the CSS.\n- `.selector().includes(property)`, asserts that the given property exists within the selector.\n- `.selector().not.includes(property)`, asserts that the given property does not exist within the selector.\n- `.selector().includes(property, value)`, asserts that the property-value pair exists within the selector.\n- `.selector().not.includes(property, value)`, asserts that the property-value pair does not exist within the selector.\n\nThe `value` within an `includes()` chain can be a custom validator function. This will pass in the resolved value as a string. Return `true` when a match is expected, false to throw an exception.\n\n```js\nassertCss('body { margin: 0 1rem }')\n  .selector('body')\n  .includes('margin', (value) =\u003e value.includes('1rem')); // true\n```\n\nThe given selector must be accurate to the expectation within the CSS. In other words:\n\n```js\nassertCss('body[data-theme] { margin: 0 }').selector('body').exists(); // false\nassertCss('body[data-theme] { margin: 0 }').selector('body').not.exists(); // true\nassertCss('body[data-theme] { margin: 0 }').selector('body[data-theme]').exists(); // true\n```\n\nAlso, note that this will not dive into at-rules. To check for existence within an at-rule, use `.atRule()` with the appropriate chain.\n\n#### `.atRule()`\n\nSimilar `.selector()` in that this checks against the current CSS at-rule and its possible values with some differences:\n\n- `.includes(value)`, completes a generic `String.includes()` against the current value. This is because various at-rule specifications do not have a repeatable construction. So `(max-width: 800px)` will match against `max-width`, `800` and `800px` as examples. You may provide a function here instead for custom matching.\n- `.selector()`, is chainable off of `.atRule()` to check for specific selectors within an at-rule with all expected chains further.\n\nSee [tests](./test/assert-css.test.js) for possible example chains.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddamato%2Fassert-css","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddamato%2Fassert-css","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddamato%2Fassert-css/lists"}