{"id":17982229,"url":"https://github.com/idered/typescript-expect-plugin","last_synced_at":"2025-03-31T06:05:54.645Z","repository":{"id":47848125,"uuid":"266641133","full_name":"Idered/typescript-expect-plugin","owner":"Idered","description":"🦥 Be lazy, write simple tests in comments. ","archived":false,"fork":false,"pushed_at":"2021-08-12T12:34:18.000Z","size":68,"stargazers_count":339,"open_issues_count":5,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-23T01:44:56.200Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/Idered.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":"2020-05-24T23:21:17.000Z","updated_at":"2025-02-05T02:32:09.000Z","dependencies_parsed_at":"2022-09-11T03:01:32.051Z","dependency_job_id":null,"html_url":"https://github.com/Idered/typescript-expect-plugin","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idered%2Ftypescript-expect-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idered%2Ftypescript-expect-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idered%2Ftypescript-expect-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idered%2Ftypescript-expect-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Idered","download_url":"https://codeload.github.com/Idered/typescript-expect-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246423731,"owners_count":20774820,"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":[],"created_at":"2024-10-29T18:13:31.222Z","updated_at":"2025-03-31T06:05:54.619Z","avatar_url":"https://github.com/Idered.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eTypescript Expect Plugin\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg  alt=\"npm\" src=\"https://img.shields.io/npm/v/typescript-expect-plugin?color=blue\" /\u003e\n  \u003cimg  alt=\"mit license\" src=\"https://img.shields.io/npm/l/typescript-expect-plugin?color=blue\" /\u003e\n  \u003cimg\n    alt=\"CI\"\n    src=\"https://github.com/Idered/typescript-expect-plugin/workflows/CI/badge.svg?event=push\"\n  /\u003e\n  \u003ca\n    href=\"https://gitter.im/typescript-expect-plugin/community?utm_source=badge\u0026amp;utm_medium=badge\u0026amp;utm_campaign=pr-badge\"\n    \u003e\u003cimg\n      alt=\"Gitter\"\n      src=\"https://badges.gitter.im/typescript-expect-plugin/community.svg\"\n  /\u003e\u003c/a\u003e\n  \u003ca href=\"https://twitter.com/intent/follow/?screen_name=Idered\"\u003e\n    \u003cimg alt=\"twitter\" src=\"https://img.shields.io/twitter/follow/Idered?style=social\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003eBe lazy, write simple tests in comments.\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://i.imgur.com/AhQK9Pl.gif\" /\u003e\n\u003c/p\u003e\n\n## Editor support\n\n✅ VS Code - flawlessly works in `Problems` panel.\n\n⏹ Sublime Text - could not get it to work but it might be possible.\n\n❔ Atom - not tested.\n\n⛔ `tsc` - plugins are disabled during build. It should work with webpack ts loader.\n\n## Quick start\n\n```sh\nnpm install typescript-expect-plugin\n```\n\n1.  Add plugin to `tsconfig.json`:\n```ts\n{\n  \"compilerOptions\": {\n    \"plugins\": [{ \"name\": \"typescript-expect-plugin\" }]\n  },\n}\n```\n\n2. Change VS Code typescript to workspace version:\n\n![](https://i.imgur.com/kK9BlMi.gif)\n\n## Usage\n\n## WARNING\n\n\u003e ⚠Tests are executed after each file change - not save. Be careful if you're going to test functions that remove or change files in your local system\n\n---\n\nThis plugin adds support for `@expect` JSDoc tag. It has the following usage pattern:\n\n```tsx\n/**\n * @expect [PARAMS] CONDITION CONDITION_PARAMETER\n */\n```\n\n- `[PARAMS]` - for example `[2, 4]` will spread two arguments to tested function.\n- `CONDITION` - check function from jest expect library. Use `ctrl+space` to see autocomplete suggestions.\n- `CONDITION_PARAMETER` - argument passed to `CONDITION` function.\n\n## Examples\n\n```tsx\n/**\n * @expect [2, 4] toBe 6\n * @expect [2, 2] toBeGreaterThan 3\n * @expect [2, 2] toBeLessThan 3\n * @expect [2, 22] toEqual 24\n */\nexport function sum(a: number, b: number) {\n  return a + b;\n}\n\n/**\n * @expect [[2, 4, 8], 4] toBeTruthy\n * @expect [[2, 4, 8], 12] toBeFalsy\n */\nexport function has(haystack: any[], needle: any) {\n  return haystack.includes(needle);\n}\n\n/**\n * @expect [[2, 8], [9, 12]] toEqual [2, 8, 9, 12]\n */\nexport function join(arr1: any[], arr2: any[]) {\n  return [...arr1, ...arr2];\n}\n\n/**\n * @expect [{\"firstName\": \"John\"}, \"lastName\", \"Doe\"] toHaveProperty \"lastName\", \"Doe Doe\"\n */\nexport function withProp(obj: Record\u003cstring, any\u003e, key: string, value: any) {\n  return {...obj, [key]: value}\n}\n```\n\n\u003e ### Test objects\n![](https://i.imgur.com/ZplL1PV.gif)\n\n\u003e ### Test arrays\n\n![](https://i.imgur.com/epox4Pu.gif)\n\n## Author\n\nHey there, I'm Kasper. If you wish to get notified about more cool typescript or react projects/tips you can follow me on twitter.\n\n\u003ca href=\"https://twitter.com/intent/follow/?screen_name=Idered\"\u003e\n  \u003cimg alt=\"twitter\" src=\"https://img.shields.io/twitter/follow/Idered?style=social\" /\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidered%2Ftypescript-expect-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidered%2Ftypescript-expect-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidered%2Ftypescript-expect-plugin/lists"}