{"id":17929177,"url":"https://github.com/skarab42/vite-plugin-vitest-typescript-assert","last_synced_at":"2025-10-19T00:34:43.454Z","repository":{"id":45374220,"uuid":"513570458","full_name":"skarab42/vite-plugin-vitest-typescript-assert","owner":"skarab42","description":"🔥 TypeScript type assertion plugin for vitest","archived":false,"fork":false,"pushed_at":"2023-10-07T02:03:00.000Z","size":484,"stargazers_count":79,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-19T01:45:06.646Z","etag":null,"topics":["assert","assertion","expect","test","type-check","type-checking","typescript","vite","vitest"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vite-plugin-vitest-typescript-assert","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/skarab42.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"skarab42","custom":"http://paypal.me/skarab"}},"created_at":"2022-07-13T15:15:09.000Z","updated_at":"2024-01-27T22:04:42.000Z","dependencies_parsed_at":"2024-06-19T20:04:06.680Z","dependency_job_id":"ad95d07f-f212-42ca-8119-db42909ec7ad","html_url":"https://github.com/skarab42/vite-plugin-vitest-typescript-assert","commit_stats":{"total_commits":56,"total_committers":1,"mean_commits":56.0,"dds":0.0,"last_synced_commit":"19fbe91bafbae540d5e361987ff6ffaa13911177"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skarab42%2Fvite-plugin-vitest-typescript-assert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skarab42%2Fvite-plugin-vitest-typescript-assert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skarab42%2Fvite-plugin-vitest-typescript-assert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skarab42%2Fvite-plugin-vitest-typescript-assert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skarab42","download_url":"https://codeload.github.com/skarab42/vite-plugin-vitest-typescript-assert/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245210856,"owners_count":20578301,"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","assertion","expect","test","type-check","type-checking","typescript","vite","vitest"],"created_at":"2024-10-28T21:07:56.260Z","updated_at":"2025-10-19T00:34:38.424Z","avatar_url":"https://github.com/skarab42.png","language":"TypeScript","funding_links":["https://github.com/sponsors/skarab42","http://paypal.me/skarab"],"categories":["Plugins"],"sub_categories":["Templates"],"readme":"\u003ch1 align=\"center\"\u003eTypeScript type assertion plugin for vitest.\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/62928763/178766707-5dd3b80f-b20f-474b-b8d4-623c00b5eac1.PNG\" alt=\"vite-plugin-vitest-typescript-assert : TypeScript assertion (test) plugin for vitest\"\u003e\n\u003c/p\u003e\n\n\u003e 📌 This plugin is in **alpha** version, and will probably stay that way for a long time, it lacks tests (a bit ironic) and real documentation! **But I can't stop myself from publishing it**. Moreover this plugin is a succession of tricks to integrate it to vitest (it would be incredible that vitest offer an official plugin system 💜). But it **seems to work** for my use cases and maybe **for you too?** I'm thinking of continuing to evolve it if I need it or if others start using it. Feel free to [contribute](contributing) or [give feedback](https://github.com/skarab42/vite-plugin-vitest-typescript-assert/issues) if you encounter any issues. **Thank you**.\n\n# Installation\n\nInstall the dependencies.\n\n```bash\npnpm add -D vitest typescript vite-plugin-vitest-typescript-assert\n# yarn and npm also works\n```\n\nSetup the plugin in `vitest.config.ts` file.\n\n```ts\nimport { defineConfig } from 'vitest/config';\nimport { vitestTypescriptAssertPlugin } from 'vite-plugin-vitest-typescript-assert';\n\nexport default defineConfig({\n  plugins: [vitestTypescriptAssertPlugin()],\n});\n```\n\n# Assertions APIs\n\nThis plugin was more than inspired by the [tsd](https://github.com/SamVerschueren/tsd) project, much of the assertion logic comes from their code.\n\nThat's why two APIs are available:\n\n```ts\n// Exactly the same behaviour as tsd (plus any bugs I might have introduced 🙈)\nimport * as tsd from 'vite-plugin-vitest-typescript-assert/tsd';\n```\n\n```ts\n// A more descriptive/flexible API with some additions.\nimport * as tssert from 'vite-plugin-vitest-typescript-assert/tssert';\n```\n\nNamed imports, alias imports and named exports are supported in both API.\n\n```ts\nimport { expectType } from 'vite-plugin-vitest-typescript-assert/tsd';\nimport { expectType as assertType } from 'vite-plugin-vitest-typescript-assert/tsd';\n\nexport { expectType as assertType } from 'vite-plugin-vitest-typescript-assert/tsd';\n```\n\n## tsd [docs](https://github.com/SamVerschueren/tsd#assertions)\n\n```ts\nexpectType\u003cExpectedType\u003e(value);\nexpectNotType\u003cExpectedType\u003e(value);\nexpectAssignable\u003cExpectedType\u003e(value);\nexpectNotAssignable\u003cExpectedType\u003e(value);\nexpectError(value);\nexpectDeprecated(expression);\nexpectNotDeprecated(expression);\nprintType(expression);\n```\n\n## tssert\n\n`tssert` supports 4 signatures for each method. You can either specify the type in the generic or the value in the first argument, but never both at the same time. But don't worry, if this happens the plugin will send you an error.\n\n```ts\nexpectType\u003cstring\u003e().assignableTo\u003cstring\u003e();\nexpectType\u003cstring\u003e().assignableTo('nyan');\nexpectType('nyan').assignableTo\u003cstring\u003e();\nexpectType('nyan').assignableTo('nyan');\n```\n\n```ts\nexpectType\u003cExpectedType\u003e().assignableTo(value);\nexpectType\u003cExpectedType\u003e().identicalTo(value);\nexpectType\u003cExpectedType\u003e().subtypeOf(value);\nexpectType\u003cExpectedType\u003e().equalTo(value);\nexpectType\u003cExpectedType\u003e().toBeDeprecated();\nexpectType\u003cExpectedType\u003e().toThrowError();\nexpectType\u003cExpectedType\u003e().toThrowError(code);\nexpectType\u003cExpectedType\u003e().toThrowError(message);\n\nexpectType\u003cExpectedType\u003e().not.assignableTo(value);\nexpectType\u003cExpectedType\u003e().not.identicalTo(value);\nexpectType\u003cExpectedType\u003e().not.subtypeOf(value);\nexpectType\u003cExpectedType\u003e().not.equalTo(value);\nexpectType\u003cExpectedType\u003e().not.toBeDeprecated();\n```\n\n# Options\n\n```ts\nvitestTypescriptAssertPlugin(options?: PluginOptions);\n```\n\nBy default the plugin applies the following configuration.\n\n```ts\nconst defaultOptions: PluginOptions = {\n  report: ['type-error', 'type-assertion'],\n  include: ['**/*.test.ts'],\n  exclude: [],\n  typescript: {\n    configName: 'tsconfig.json',\n    searchPath: process.cwd(),\n    compilerOptions: {},\n  },\n};\n```\n\n- `type-error`: Report the errors raised by the TS compiler.\n- `type-assertion`: Report the errors raised by the assertion library.\n\n```ts\nexport interface PluginOptions {\n  report?: 'type-error' | 'type-assertion';\n  include?: string | string[];\n  exclude?: string | string[];\n  typescript?: TypeScriptConfigOptions;\n}\n\ninterface TypeScriptConfigOptions {\n  configName?: string;\n  searchPath?: string;\n  compilerOptions?: ts.CompilerOptions;\n}\n```\n\n# Contributing 💜\n\nSee [CONTRIBUTING.md](https://github.com/skarab42/vite-plugin-vitest-typescript-assert/blob/main/CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskarab42%2Fvite-plugin-vitest-typescript-assert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskarab42%2Fvite-plugin-vitest-typescript-assert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskarab42%2Fvite-plugin-vitest-typescript-assert/lists"}