···117117- **CLI:** `--coverage.include <pattern>`
118118- **Config:** [coverage.include](/config/#coverage-include)
119119120120-Files included in coverage as glob patterns. May be specified more than once when using multiple patterns (default: `**`)
120120+Files included in coverage as glob patterns. May be specified more than once when using multiple patterns. By default only files covered by tests are included.
121121122122### coverage.exclude
123123124124- **CLI:** `--coverage.exclude <pattern>`
125125- **Config:** [coverage.exclude](/config/#coverage-exclude)
126126127127-Files to be excluded in coverage. May be specified more than once when using multiple extensions (default: Visit [`coverage.exclude`](https://vitest.dev/config/#coverage-exclude))
127127+Files to be excluded in coverage. May be specified more than once when using multiple extensions.
128128129129### coverage.clean
130130···929929930930- **CLI:** `--standalone`
931931932932-Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: `false`)
932932+Start Vitest without running tests. Tests will be running only on change. This option is ignored when CLI file filters are passed. (default: `false`)
+29
docs/guide/migration.md
···116116117117Note that now if you provide an arrow function, you will get [`<anonymous> is not a constructor` error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_constructor) when the mock is called.
118118119119+### Standalone mode with filename filter
120120+121121+To improve user experience, Vitest will now start running the matched files when [`--standalone`](/guide/cli#standalone) is used with filename filter.
122122+123123+```sh
124124+# In Vitest v3 and below this command would ignore "math.test.ts" filename filter.
125125+# In Vitest v4 the math.test.ts will run automatically.
126126+$ vitest --standalone math.test.ts
127127+```
128128+129129+This allows users to create re-usable `package.json` scripts for standalone mode.
130130+131131+::: code-group
132132+```json [package.json]
133133+{
134134+ "scripts": {
135135+ "test:dev": "vitest --standalone"
136136+ }
137137+}
138138+```
139139+```bash [CLI]
140140+# Start Vitest in standalone mode, without running any files on start
141141+$ pnpm run test:dev
142142+143143+# Run math.test.ts immediately
144144+$ pnpm run test:dev math.test.ts
145145+```
146146+:::
147147+119148### Deprecated APIs are Removed
120149121150Vitest 4.0 removes some deprecated APIs, including:
+29
test/cli/test/standalone.test.ts
···11+import { test } from 'vitest'
22+import { runVitest } from '../../test-utils'
33+44+test('test run is not started when --standalone', async () => {
55+ const { vitest } = await runVitest({
66+ root: 'fixtures/standalone',
77+ standalone: true,
88+ watch: true,
99+ })
1010+1111+ await vitest.waitForStdout('Vitest is running in standalone mode. Edit a test file to rerun tests.')
1212+ await vitest.waitForStdout('PASS Waiting for file changes...')
1313+ await vitest.waitForStdout('press h to show help, press q to quit')
1414+})
1515+1616+test('test run is started when --standalone and filename filter', async () => {
1717+ const { vitest } = await runVitest({
1818+ root: 'fixtures/standalone',
1919+ standalone: true,
2020+ watch: true,
2121+ }, ['basic.test.ts'])
2222+2323+ await vitest.waitForStdout('✓ basic.test.ts > example')
2424+ await vitest.waitForStdout('Test Files 1 passed (1)')
2525+ await vitest.waitForStdout('Tests 1 passed (1)')
2626+2727+ await vitest.waitForStdout('PASS Waiting for file changes...')
2828+ await vitest.waitForStdout('press h to show help, press q to quit')
2929+})
+5
test/cli/fixtures/standalone/basic.test.ts
···11+import { expect, test } from "vitest";
22+33+test("example", () => {
44+ expect(1).toBe(1);
55+})
+3
test/cli/fixtures/standalone/vitest.config.ts
···11+import { defineConfig } from 'vitest/config'
22+33+export default defineConfig({})
···820820 },
821821 standalone: {
822822 description:
823823- 'Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: `false`)',
823823+ 'Start Vitest without running tests. Tests will be running only on change. This option is ignored when CLI file filters are passed. (default: `false`)',
824824 },
825825 mergeReports: {
826826 description:
+1-1
packages/vitest/src/node/types/config.ts
···912912 *
913913 * Vitest will only run tests if it's called programmatically or the test file changes.
914914 *
915915- * CLI file filters will be ignored.
915915+ * If CLI file filters are passed, standalone mode is ignored.
916916 */
917917 standalone?: boolean
918918