{"id":15809253,"url":"https://github.com/zordius/dom-validate","last_synced_at":"2025-08-21T08:09:38.087Z","repository":{"id":57214828,"uuid":"85031355","full_name":"zordius/dom-validate","owner":"zordius","description":"A tool to check required/refused DOM nodes, can also output TAP or JUnit reports","archived":false,"fork":false,"pushed_at":"2017-03-28T07:39:51.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-20T14:25:11.186Z","etag":null,"topics":["broken-links","command-line-tool","html","junit","tap","validator","xunit"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zordius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-15T05:07:52.000Z","updated_at":"2017-03-20T04:41:29.000Z","dependencies_parsed_at":"2022-09-07T09:00:58.425Z","dependency_job_id":null,"html_url":"https://github.com/zordius/dom-validate","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/zordius/dom-validate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zordius%2Fdom-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zordius%2Fdom-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zordius%2Fdom-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zordius%2Fdom-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zordius","download_url":"https://codeload.github.com/zordius/dom-validate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zordius%2Fdom-validate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271448360,"owners_count":24761433,"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-08-21T02:00:08.990Z","response_time":74,"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":["broken-links","command-line-tool","html","junit","tap","validator","xunit"],"created_at":"2024-10-05T03:21:00.796Z","updated_at":"2025-08-21T08:09:38.068Z","avatar_url":"https://github.com/zordius.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dom-validate\n\nA tool to check required/refused DOM nodes, can also output TAP or JUnit reports\n\n[![npm version](https://img.shields.io/npm/v/dom-validate.svg)](https://www.npmjs.org/package/dom-validate) [![Build Status](https://travis-ci.org/zordius/dom-validate.svg?branch=master)](https://travis-ci.org/zordius/dom-validate)\n\n## Usage\n\n```shell\n# Install\nnpm install dom-validate -g\n\n# Check for Google page, there should be a .lsb element\nnode-validate -u 'https://google.com/' -r '.lsb' -v=2\n\n# Check for Yahoo page, there should not be any empty link\nnode-validate -u 'https://us.yahoo.com/' -n 'a[href=\"\"]' -v=2\n\n# Yes, there should not be any broken images...check again\nnode-validate -u 'https://us.yahoo.com/' -n 'img[src=\"\"]' -v=2\n```\n\n## Command line options\n* **-u** specify a url string to verify\n* **-r** specify the css selector for the required element\n* **-n** specify the css selector for the refused element\n* **-v** show verbose message for the error cases\n* **-v=2** show verbose message for the success cases\n* **-v=3** show verbose message for the html of css selector selected elements\n* **-c** [BATCH] specify a local yaml config file to do batch check\n* **-b** [BATCH] specify base URL\n* **-t** [BATCH] output result as \u003ca href=\"https://testanything.org/\"\u003eTAP\u003c/a\u003e format\n\nThe exit code will be the number of failed cases.\n\n## BATCH check example\n\nTry this command: `node-validate -c sample.yaml -b https://tw.search.yahoo.com -v=2`\n\nThe content of \u003ca href=\"sample.yaml\"\u003esample.yaml\u003c/a\u003e can be:\n```yaml\n# do one check for one URL\nhttp://google.com:\n  require: .lsb\n\n# do 2 required element checks for the URL\nhttp://us.yahoo.com:\n  require:\n    - body \u003e div\n    - form\n\n# do many required and refused element check for the URL\n/search?p=test:\n  require:\n    - body \u003e div\n    - form button\n  refuse:\n    - 'a[href=\"\"]'\n```\n\nSample output:\n```\n# check for http://google.com\nOK: required element \".lsb\" found(2)\n# check for http://us.yahoo.com\nOK: required element \"body \u003e div\" found(2)\nOK: required element \"form\" found(1)\n# check for https://tw.search.yahoo.com/search?p=test\nOK: required element \"body \u003e div\" found(1)\nOK: required element \"form button\" found(2)\nOK: refused element \"a[href=\"\"]\" not found\n```\n\n## Output test report\n\nTry this to save \u003ca href=\"https://testanything.org/\"\u003eTAP\u003c/a\u003e report file as result.tap:\n```sh\nnode-validate -c sample.yaml -b https://tw.search.yahoo.com -t \u003e result.tap\n```\n\nYou may also get \u003ca href=\"http://junit.org/\"\u003eJUnit (xUnit)\u003c/a\u003e report file by:\n```sh\nnpm install tap-xunit -g\nnode-validate -c sample.yaml -b https://tw.search.yahoo.com -t | tap-xunit \u003e junit-result.xml\n```\n\n## node module usage\n\n```javascript\nvar DV = require('dom-validate');\n\n// validate by a HTML string\nDV.validateHTML(htmlString, options);\n\n// validate by an URL\nDV.validateURL(urlString, options);\n\n// validate by a yaml config file\nDV.validateByYaml(yamlFileName, options);\n```\n\n**Options**\n```javascript\nvar options = {\n    url: 'http://sample.com',                  // URL for error or debug message\n    baseURL: 'https://test.com',               // Will be used for relative URL when call .validateByYaml()\n    require: 'body',                           // String or Array of CSS selector to check\n    refuse: ['a[href=\"\"]', 'img[src=\"\"]'],     // String or Array of CSS selector to check\n    exit: false,                               // true to end process when test done, the exit code will be number of failed case\n    verbose: false,                            // true to show message for success cases\n                                               // 2 to show verbose message for the success cases\n                                               // 3 to show verbose message for the html of css selector selected elements\n    report: false,                             // true to output TAP report\n    callback: function (err, options) {        // Will be executed for every cases\n        if (err) {\n            // err will be the error message string when the case failed\n            console.log('ERROR!' + err);\n            return;\n        } else {\n            // success case\n            connsole.log('OK!');\n        }\n        // You can get the whole options object in callback function, plus:\n        // options.selector will be the CSS selector of current case\n        // options.nodes will be the selected nodes (check cheerio document)\n        // options.task will be 'require' or 'refuse'\n    }\n};\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzordius%2Fdom-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzordius%2Fdom-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzordius%2Fdom-validate/lists"}