{"id":24614220,"url":"https://github.com/parzh/tyte","last_synced_at":"2025-09-16T09:57:35.758Z","repository":{"id":51439617,"uuid":"330264260","full_name":"parzh/tyte","owner":"parzh","description":null,"archived":false,"fork":false,"pushed_at":"2021-06-14T10:42:53.000Z","size":91,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-18T23:40:24.787Z","etag":null,"topics":["jest","testing","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/parzh.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":"2021-01-16T21:47:26.000Z","updated_at":"2021-10-27T23:31:06.000Z","dependencies_parsed_at":"2022-09-14T09:50:13.847Z","dependency_job_id":null,"html_url":"https://github.com/parzh/tyte","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parzh%2Ftyte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parzh%2Ftyte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parzh%2Ftyte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parzh%2Ftyte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parzh","download_url":"https://codeload.github.com/parzh/tyte/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244273132,"owners_count":20426867,"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":["jest","testing","typescript"],"created_at":"2025-01-24T21:15:38.786Z","updated_at":"2025-09-16T09:57:30.720Z","avatar_url":"https://github.com/parzh.png","language":"TypeScript","readme":"# `tyte`\r\n\r\nWrite Jest tests for TypeScript types.\r\n\r\n# Usage\r\n\r\n\u003e Also see **Caveats** section below\r\n\r\n```ts\r\nexport type MyNumber = number;\r\nexport type MyFunction = (input: string) =\u003e boolean;\r\n```\r\n\r\n## Positive testing:\r\n\r\n```ts\r\ntest(\"MyNumber should resolve to a number\", tyte((value: MyNumber) =\u003e {\r\n\ttyte.expectType\u003cnumber\u003e(value);\r\n}));\r\n\r\ndescribe(\"MyFunction\", () =\u003e {\r\n\tit(\"should take a string input\", tyte((subject: MyFunction) =\u003e {\r\n\t\ttyte.fn.expectParams\u003c[string]\u003e(subject);\r\n\t}));\r\n\r\n\tit(\"should return a boolean\", tyte((subject: MyFunction) =\u003e {\r\n\t\ttyte.fn.expectReturns\u003cboolean\u003e(subject);\r\n\t}));\r\n});\r\n```\r\n\r\n## Negative testing:\r\n\r\n```ts\r\ntest(\"MyNumber should not resolve to a string\", tyte((value: MyNumber) =\u003e {\r\n\t// @ts-expect-error\r\n\ttyte.expectType\u003cstring\u003e(value);\r\n}));\r\n```\r\n\r\n## Use several subjects in test callback:\r\n\r\n```ts\r\ntest(\"MyNumber should resolve to a number\", tyte((\r\n\tvalue: MyNumber,\r\n\tvalues: MyNumber[],\r\n) =\u003e {\r\n\ttyte.expectType\u003cnumber\u003e(value);\r\n\ttyte.expectType\u003cnumber[]\u003e(values);\r\n}));\r\n```\r\n\r\n## Iterate over several subjects in [`.each` methods]:\r\n\r\n```ts\r\ntype Forward = \"forward\";\r\ntype Vertical = \"up\" | \"down\" | Forward;\r\ntype Horizontal = \"left\" | \"right\" | Forward;\r\n\r\ntest.each([\r\n\t[ \"Vertical\", tyte.subject as Vertical \u0026 Forward ],\r\n\t[ \"Horizontal\", tyte.subject as Horizontal \u0026 Forward ],\r\n])(\"%s should include 'forward'\", (identifier, subject) =\u003e {\r\n\ttyte.expectType\u003c\"forward\"\u003e(subject);\r\n});\r\n```\r\n\r\n## Caveats\r\n\r\n- Currently, it is not possible to use `tyte()` as a function in [`.each` methods], as in:\r\n\r\n\t```ts\r\n\ttest.each(list)(\"should ...\", tyte((element) =\u003e {\r\n\t\t// ...\r\n\t}));\r\n\t```\r\n\r\n\tSuch code will produce compilation errors.\r\n\r\n\t\u003e Any suggestions and PRs are very welcome!\r\n\r\n\r\n  [`.each` methods]: https://jestjs.io/docs/en/api#methods\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparzh%2Ftyte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparzh%2Ftyte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparzh%2Ftyte/lists"}