{"id":42691791,"url":"https://github.com/luileito/asserter","last_synced_at":"2026-01-29T13:05:20.365Z","repository":{"id":57185067,"uuid":"106743285","full_name":"luileito/asserter","owner":"luileito","description":"A tiny assertion lib for both nodejs and the browser.","archived":false,"fork":false,"pushed_at":"2022-09-20T21:14:33.000Z","size":84,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-19T20:19:41.223Z","etag":null,"topics":["test-suite","testing","unit-testing"],"latest_commit_sha":null,"homepage":null,"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/luileito.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-10-12T20:43:14.000Z","updated_at":"2022-09-20T21:13:25.000Z","dependencies_parsed_at":"2022-09-14T09:50:12.522Z","dependency_job_id":null,"html_url":"https://github.com/luileito/asserter","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/luileito/asserter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luileito%2Fasserter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luileito%2Fasserter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luileito%2Fasserter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luileito%2Fasserter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luileito","download_url":"https://codeload.github.com/luileito/asserter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luileito%2Fasserter/sbom","scorecard":{"id":603395,"data":{"date":"2025-08-11","repo":{"name":"github.com/luileito/asserter","commit":"92acab1da9258815859857f70fbb2184fdc47ea3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-21T00:59:07.443Z","repository_id":57185067,"created_at":"2025-08-21T00:59:07.443Z","updated_at":"2025-08-21T00:59:07.443Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28877889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T10:31:27.438Z","status":"ssl_error","status_checked_at":"2026-01-29T10:31:01.017Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["test-suite","testing","unit-testing"],"created_at":"2026-01-29T13:05:09.030Z","updated_at":"2026-01-29T13:05:20.348Z","avatar_url":"https://github.com/luileito.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asserter\n\nA tiny assertion lib (ES5+ compliant) with zero dependencies and zero configuration.\nWritten in [isomorphic JavaScript](https://en.wikipedia.org/wiki/Isomorphic_JavaScript)\n(works for both NodeJS and the browser),\nthis software is meant to run quick and dirty unit tests: just load the lib and use it!\n\nThe source code is about 200 lines (fully documented),\nthe minified version is just 4 Kb (1 Kb if gzipped).\n\n## Disclaimer\n\nThere are many good unit testing libs out there for NodeJS and the browser (and for both environments).\nHowever, everything I tried so far either works well in NodeJS,\nor needs to inject many external dependencies in the browser,\nor requires complex setups (and most unit tests are not that complex eventually).\nThis library simply gets the job done.\n\n## Minimal working example\n\nA test is defined as `asserter.test('label').\u003cmethod\u003e(arg1, arg2)`,\nor using the [alternative syntax](#alternative-syntax):\n`asserter.test('label').that(arg1).\u003cmethod\u003e(arg2)`.\n\nOnce you've defined a set of tests, just call `assert.run()` to run all tests.\n\n### In NodeJS\n\n```js\nvar asserter = require('asserter');\nasserter.test('Equals def').equals(1, 2);\n// or: asserter.test('Equals alt').that(1).equals(2);\nasserter.test('Not contains string').not().contains('Hi there', 'foo');\n// or: asserter.test('Not contains string').that('Hi there').not().contains('foo');\nasserter.run();\n```\n\n![Sample output](sample-node.png?raw=true)\n\nOr you can run `npm test` to see it working.\n\n### In the browser\n\n```html\n\u003cscript src=\"asserter.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\nasserter.test('Equals def').equals(1, 2);\n// or: asserter.test('Equals alt').that(1).equals(2);\nasserter.test('Not contains string').not().contains('Hi there', 'foo');\n// or: asserter.test('Not contains string').that('Hi there').not().contains('foo');\nasserter.run();\n\u003c/script\u003e\n```\n\n![Sample output](sample-browser.png?raw=true)\n\nOr you can open `test.html` with your browser to see it working (hit `F12` to open the developer console).\n\n## Supported tests\n\n* `equals(arg1, arg2)`\n\nTest if two arguments are equal (truthy comparison).\n\n* `strictEquals(arg1, arg2)` or `is(arg1, arg2)`\n\nTest if two arguments are equal (strict comparison).\n\n* `isGreaterThan(arg1, arg2)`\n\nTest if `arg1` is greater than `arg2`.\n\n* `isGreaterThanOrEquals(arg1, arg2)`\n\nTest if `arg1` is greater than or equal `arg2`.\n\n* `isLessThan(arg1, arg2)`\n\nTest if `arg1` is less than `arg2`.\n\n* `isLessThanOrEquals(arg1, arg2)`\n\nTest if `arg1` is less than or equal `arg2`.\n\n* `matches(str, re)`\n\nTest if string `str` matches regular expression `re`.\n\n* `contains(str, sub)`\n\nTest if string `str` contains string `sub`.\n\n* `hasType(arg, type)`\n\nTest if `arg` is of type `type`.\n\n* `inherits(arg, type)`\n\nTest if `arg` is an instance of `type`.\n\n* `throws(arg)`\n\nTest if `arg` throws an error.\n\n* `not()`\n\nThis will negate the current test result.\nSee examples above or below.\n\n## Features\n\n### Test methods are chainable\n\n```js\nasserter\n.test('Equals').equals(1, 2)\n.test('Not contains string').not().contains('Hi there', 'foo')\n.run()\n```\n\n### Tests can be grouped (poor man's test suites)\n\n```js\nasserter\n// Start test suite.\n.test('Equals 1').equals(1, 1)\n.test('Equals undef').equals(null, undefined)\n.run('Equality tests')\n// Start another test suite.\n.test('Contains string').matches('foo', /o+/)\n.test('Not contains string').not().contains('Hi there', 'foo')\n.run('String tests')\n```\n\n### Labels have sprintf capability\n\n```js\nasserter\n.test('Hi %s', 'there').isGreaterThan(2, 1)\n.run('Test %s began on %s', 42, new Date)\n```\n\n### Method arguments can be anything\n\nIf you pass in *arrays*, they will be casted to strings when testing equality; e.g., `[1,2]` becomes `'1,2'`.\n```js\nasserter\n.test('Array test').equals([1,2], [1,2])\n.run();\n```\n\nIf you pass in *objects*, they will be casted to JSON when testing equality; e.g., `{foo:1}` becomes `'{\"foo\":1}'`.\n```js\nasserter\n.test('Object test').equals({foo:1}, {foo:1})\n.run();\n```\n\n**Note:** This casting is not performed when testing for *strict* equality.\n\nFinally, if you pass in *functions*, their return values will be tested in any case.\n```js\nasserter\n.test('Function test #1').equals(function() { return 2; }, function() { return 2; })\n.test('Function test #2').equals(2, function() { return 2; })\n.test('Function test #3').equals(function() { return 2; }, 2)\n.test('Should be undefined').equals(function() { return; }, undefined)\n.run();\n```\n\n### Alternative syntax\n\nA more convenient syntax is supported, where values and operators are explicitly declared and are thus easier to spot,\nwhich allows to be read e.g. as \"Test that {value} is greater than {value}\".\n\n```js\nasserter\n// Start test suite.\n.test('Equals 1').that(1).equals(1)\n.test('Equals undef').that(null).equals(undefined)\n.run('Equality tests')\n// Start another test suite.\n.test('Contains string').that('foo').matches(/o+/)\n.test('Not contains string').that('Hi there').not().contains('foo')\n.run('String tests')\n```\n\n## Documentation\n\nRun `npm run docs` to generate the documentation in the `docs` directory (autogenerated).\n\n**Note:** You need `jsdoc` to run this command. If that's not the case, run `[sudo] npm i -g jsdoc`.\n\n## Minification\n\nRun `npm run dist` to create the `assert.min.js` file.\nThis will optimize file requests if you use this lib in a browser.\n\n**Note:** You need `uglifyjs` to run this command. If that's not the case, run `[sudo] npm i -g uglifyjs`.\n\n## Code linting\n\nRun `npm run lint` to analyze the source code for potential errors.\n\n**Note:** You need `eslint` to run this command. If that's not the case, run `[sudo] npm i -g eslint`.\n\n## Coverage tests\n\nRun `npm run cover` to generate a report in the `coverage` directory (autogenerated).\n\n**Note:** You need both `jasmine` and `istanbul` to run this command. If that's not the case, run `[sudo] npm i -g jasmine istanbul`.\n\n\n## License\n\nThis libray is released with the [MIT license](LICENSE).\nThe only requirement is that you keep my copyright notice intact when you repurpose, redistribute, or reuse this code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluileito%2Fasserter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluileito%2Fasserter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluileito%2Fasserter/lists"}