{"id":16820599,"url":"https://github.com/nighttrax/strictly-chai","last_synced_at":"2026-05-20T03:31:39.969Z","repository":{"id":57372288,"uuid":"132327033","full_name":"NiGhTTraX/strictly-chai","owner":"NiGhTTraX","description":"A statically typed subset of chai assertions","archived":false,"fork":false,"pushed_at":"2018-09-12T05:06:22.000Z","size":998,"stargazers_count":0,"open_issues_count":10,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T02:28:35.768Z","etag":null,"topics":["assert","bdd","chai","testing","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NiGhTTraX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-06T10:09:30.000Z","updated_at":"2018-08-06T20:27:51.000Z","dependencies_parsed_at":"2022-09-01T17:31:39.689Z","dependency_job_id":null,"html_url":"https://github.com/NiGhTTraX/strictly-chai","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/NiGhTTraX%2Fstrictly-chai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiGhTTraX%2Fstrictly-chai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiGhTTraX%2Fstrictly-chai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiGhTTraX%2Fstrictly-chai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NiGhTTraX","download_url":"https://codeload.github.com/NiGhTTraX/strictly-chai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244056675,"owners_count":20390773,"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":["assert","bdd","chai","testing","typescript"],"created_at":"2024-10-13T10:57:26.607Z","updated_at":"2026-05-20T03:31:39.922Z","avatar_url":"https://github.com/NiGhTTraX.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build\nStatus](https://travis-ci.com/NiGhTTraX/strictly-chai.svg?branch=master)](https://travis-ci.com/NiGhTTraX/strictly-chai) \n[![codecov](https://codecov.io/gh/NiGhTTraX/strictly-chai/branch/master/graph/badge.svg)](https://codecov.io/gh/NiGhTTraX/strictly-chai)\n[![Greenkeeper badge](https://badges.greenkeeper.io/NiGhTTraX/strictly-chai.svg)](https://greenkeeper.io/)\n\n\u003e A statically typed subset of [chai](http://www.chaijs.com) assertions written\nin TypeScript.\n\n\n## Usage\n\n![object-contains](./docs/object-contains.png)\n\n![demo](./docs/demo.gif)\n\nThis library exports a subset of chai's [BDD API](http://www.chaijs.com/api/bdd/)\nso check out their docs on usage. The only difference is that the `.equal`\nassertion is by default deep (equivalent to `.deep.equal`).\n\n\n## Philosophy\n\n```js\nexpect(new Set([1, 2])).to.contain('a');\n```\n\nWhile the above is perfectly valid JS and chai will throw an AssertionError at\nruntime, it was this author's desire to turn that into a compile time error when\nusing TypeScript.\n\nUsing this library instead of `chai.expect` in the assertion above will\nfail to compile with the following:\n\n```\nTS2345: Argument of type '\"a\"' is not assignable to parameter of type 'number'.\n```\n\n\n## But wait, what about `@types/chai`?\n\n`@types/chai` declares most arguments as `any` so using chai directly in\nTypeScript will not provide meaningful type checking.\n\nCould this library export stricter types to be used in place of `@types/chai`,\ninstead of also providing a \"re-implementation\" (the current implementation is\na drop-in replacement) of chai? Perhaps, but the real strength of this library\nis the ability to extend it for new types - see below for details.\n\n\n## Plugins\n\nYou can extend this library, similarly to how `chai.use` works, and keep type\nsafety using `extend`:\n\n```ts\nimport { extend, Expect, IsType, Plugin } from 'strictly-chai/extend';\n\ntype MyAwesomeType = {\n  myAwesomeProp: 42\n};\n\ninterface MyAwesomeAssertion {\n  to: {\n    be: {\n      awesome: (expected: number) =\u003e void;\n    }\n  }\n}\n\nconst isMyAwesomeType: IsType\u003cMyAwesomeType\u003e = (actual: any): actual is MyAwesomeType =\u003e\n  ((actual as MyAwesomeType).myAwesomeProp === 42);\n\nconst plugin: Plugin\u003cMyAwesomeType, MyAwesomeAssertion\u003e = chai =\u003e {\n  // You have access to the chai instance so you can do chai.use() here.\n\n  const myAwesomeExpect: Expect\u003cMyAwesomeType, MyAwesomeAssertion\u003e = actual =\u003e ({\n    to: {\n      be: {\n        awesome: () =\u003e {}\n      }\n    }\n  });\n\n  return {\n    isType: isMyAwesomeType,\n    expect: myAwesomeExpect\n  };\n};\n\nconst expect = extend(plugin);\n\n// This is our awesome assertion.\nexpect({ myAwesomeProp: 42 }).to.be.awesome(23);\n\n// TS2345: Argument of type '\"foo\"' is not assignable to parameter of type 'number'.\nexpect({ myAwesomeProp: 42 }).to.be.awesome('foo');\n\n// This is from the inherited base assertions.\nexpect('foobar').to.contain('foo');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnighttrax%2Fstrictly-chai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnighttrax%2Fstrictly-chai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnighttrax%2Fstrictly-chai/lists"}