diff --git a/docs/advanced/api.md b/docs/advanced/api.md index fa4990699fda..e21fe2f0ae5a 100644 --- a/docs/advanced/api.md +++ b/docs/advanced/api.md @@ -52,7 +52,6 @@ Vitest instance requires the current test mode. It can be either: - `test` when running runtime tests - `benchmark` when running benchmarks -- `typecheck` when running type tests ### mode @@ -64,10 +63,6 @@ Test mode will only call functions inside `test` or `it`, and throws an error wh Benchmark mode calls `bench` functions and throws an error, when it encounters `test` or `it`. This mode uses `benchmark.include` and `benchmark.exclude` options in the config to find benchmark files. -#### typecheck - -Typecheck mode doesn't _run_ tests. It only analyses types and gives a summary. This mode uses `typecheck.include` and `typecheck.exclude` options in the config to find files to analyze. - ### start You can start running tests or benchmarks with `start` method. You can pass an array of strings to filter test files. diff --git a/docs/config/index.md b/docs/config/index.md index 028b1d897793..841e1e8b26d2 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -547,7 +547,7 @@ export default defineConfig({ ### poolMatchGlobs -- **Type:** `[string, 'threads' | 'forks' | 'vmThreads'][]` +- **Type:** `[string, 'threads' | 'forks' | 'vmThreads' | 'typescript'][]` - **Default:** `[]` - **Version:** Since Vitest 0.29.4 @@ -1637,6 +1637,24 @@ Changes the order in which setup files are executed. Options for configuring [typechecking](/guide/testing-types) test environment. +#### typecheck.enabled + +- **Type**: `boolean` +- **Default**: `false` +- **CLI**: `--typecheck`, `--typecheck.enabled` +- **Version**: Since Vitest 1.0.0-beta.3 + +Enable typechecking alongside your regular tests. + +#### typecheck.only + +- **Type**: `boolean` +- **Default**: `false` +- **CLI**: `--typecheck.only` +- **Version**: Since Vitest 1.0.0-beta.3 + +Run only typecheck tests, when typechecking is enabled. When using CLI, this option will automatically enable typechecking. + #### typecheck.checker - **Type**: `'tsc' | 'vue-tsc' | string` diff --git a/docs/guide/cli.md b/docs/guide/cli.md index 5d7b7317f5ef..c4569ec8a106 100644 --- a/docs/guide/cli.md +++ b/docs/guide/cli.md @@ -96,6 +96,9 @@ Run only [benchmark](https://vitest.dev/guide/features.html#benchmarking-experim | `--inspect-brk` | Enables Node.js inspector with break | | `--bail ` | Stop test execution when given number of tests have failed | | `--retry ` | Retry the test specific number of times if it fails | +| `--typecheck [options]` | Custom options for typecheck pool. If passed without options, enables typechecking | +| `--typecheck.enabled` | Enable typechecking alongside tests (default: `false`) | +| `--typecheck.only` | Run only typecheck tests. This automatically enables typecheck (default: `false`) | | `-h, --help` | Display available CLI options | ::: tip diff --git a/docs/guide/testing-types.md b/docs/guide/testing-types.md index 258e970ab4c4..eb2f167dbf68 100644 --- a/docs/guide/testing-types.md +++ b/docs/guide/testing-types.md @@ -66,12 +66,12 @@ assertType(answr) // ## Run typechecking -Add this command to your `scripts` section in `package.json`: +To enabled typechecking, just add `--typecheck` flag to your Vitest command in `package.json`: ```json { "scripts": { - "typecheck": "vitest typecheck" + "test": "vitest --typecheck" } } ``` @@ -80,13 +80,13 @@ Now you can run typecheck: ```sh # npm -npm run typecheck +npm run test # yarn -yarn typecheck +yarn test # pnpm -pnpm run typecheck +pnpm run test ``` Vitest uses `tsc --noEmit` or `vue-tsc --noEmit`, depending on your configuration, so you can remove these scripts from your pipeline. diff --git a/packages/runner/src/utils/tasks.ts b/packages/runner/src/utils/tasks.ts index 40244da59c8a..d692a7995494 100644 --- a/packages/runner/src/utils/tasks.ts +++ b/packages/runner/src/utils/tasks.ts @@ -7,8 +7,8 @@ function isAtomTest(s: Task): s is Test | Custom { export function getTests(suite: Arrayable): (Test | Custom)[] { const tests: (Test | Custom)[] = [] - const suite_arr = toArray(suite) - for (const s of suite_arr) { + const arraySuites = toArray(suite) + for (const s of arraySuites) { if (isAtomTest(s)) { tests.push(s) } diff --git a/packages/ui/client/components/Suites.vue b/packages/ui/client/components/Suites.vue index 492b10d3bb3e..c9a1d8038194 100644 --- a/packages/ui/client/components/Suites.vue +++ b/packages/ui/client/components/Suites.vue @@ -23,6 +23,7 @@ async function onRunCurrent() {