From dbb880cc9806cb239150446e31f1678da968f968 Mon Sep 17 00:00:00 2001 From: Jean Burellier Date: Sun, 22 Mar 2026 11:04:15 +0100 Subject: [PATCH] doc: add logLevel for vitest-pool-worker --- ...26-03-22-vitest-pool-workers-log-level.mdx | 28 +++++++++++++++++++ .../vitest-integration/configuration.mdx | 3 ++ .../testing/vitest-integration/debugging.mdx | 19 +++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/content/changelog/workers/2026-03-22-vitest-pool-workers-log-level.mdx diff --git a/src/content/changelog/workers/2026-03-22-vitest-pool-workers-log-level.mdx b/src/content/changelog/workers/2026-03-22-vitest-pool-workers-log-level.mdx new file mode 100644 index 000000000000000..36cdae3a3dff8dd --- /dev/null +++ b/src/content/changelog/workers/2026-03-22-vitest-pool-workers-log-level.mdx @@ -0,0 +1,28 @@ +--- +title: Configurable log level for @cloudflare/vitest-pool-workers +description: You can now control the verbosity of pool log messages when using the Workers Vitest integration. +products: + - workers +date: 2026-03-22 +--- + +The [`@cloudflare/vitest-pool-workers`](/workers/testing/vitest-integration/) package now supports a `logLevel` option in `cloudflareTest()`, letting you control the verbosity of `[vpw:*]` pool log messages. + +Previously, the pool always logged at the `verbose` level. The new default is `"info"`, which reduces noise during test runs. You can set `logLevel` to `"verbose"` or `"debug"` for detailed debugging output, or `"none"` to suppress all pool messages. + +```ts +import { cloudflareTest } from "@cloudflare/vitest-pool-workers"; +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + plugins: [ + cloudflareTest({ + logLevel: "warn", + }), + ], +}); +``` + +Accepted values are `"none"`, `"error"`, `"warn"`, `"info"`, `"debug"`, and `"verbose"`. + +See the [configuration reference](/workers/testing/vitest-integration/configuration/#cloudflaretestoptions) for full details. diff --git a/src/content/docs/workers/testing/vitest-integration/configuration.mdx b/src/content/docs/workers/testing/vitest-integration/configuration.mdx index 2ed6e1c123c2c98..d6f06d5a54d272f 100644 --- a/src/content/docs/workers/testing/vitest-integration/configuration.mdx +++ b/src/content/docs/workers/testing/vitest-integration/configuration.mdx @@ -121,6 +121,9 @@ Options passed directly to `cloudflareTest()`. - `main`: string optional - Entry point to Worker run in the same isolate/context as tests. This option is required to use Durable Objects without an explicit `scriptName` if classes are defined in the same Worker. This file goes through Vite transforms and can be TypeScript. Note that `import module from ""` inside tests gives exactly the same `module` instance as is used internally for `exports` and Durable Object bindings. If `wrangler.configPath` is defined and this option is not, it will be read from the `main` field in that configuration file. +- `logLevel`: `"none" | "error" | "warn" | "info" | "debug" | "verbose"` optional, defaults to `"info"` + - Controls the verbosity of `[vpw:*]` pool log messages. Set to `"verbose"` or `"debug"` for detailed debugging output, or `"none"` to suppress all pool messages. + - `miniflare`: `SourcelessWorkerOptions & { workers?: WorkerOptions\[]; }` optional - Use this to provide configuration information that is typically stored within the [Wrangler configuration file](/workers/wrangler/configuration/), such as [bindings](/workers/runtime-apis/bindings/), [compatibility dates](/workers/configuration/compatibility-dates/), and [compatibility flags](/workers/configuration/compatibility-flags/). The `WorkerOptions` interface is defined [here](https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare#interface-workeroptions). Use the `main` option above to configure the entry point, instead of the Miniflare `script`, `scriptPath`, or `modules` options. diff --git a/src/content/docs/workers/testing/vitest-integration/debugging.mdx b/src/content/docs/workers/testing/vitest-integration/debugging.mdx index f41ccfd46d95a33..3a6b02e0205ecbf 100644 --- a/src/content/docs/workers/testing/vitest-integration/debugging.mdx +++ b/src/content/docs/workers/testing/vitest-integration/debugging.mdx @@ -85,3 +85,22 @@ To setup VS Code for breakpoint debugging in your Worker tests, create a `.vscod ``` Select **Debug Workers tests** at the top of the **Run & Debug** panel to open an inspector with Vitest and attach a debugger to the Workers runtime. Then you can add breakpoints to your test files and start debugging. + +## Increase log verbosity + +If your tests are failing or behaving unexpectedly, increasing the pool log level can surface useful diagnostic information. Set `logLevel` to `"verbose"` or `"debug"` in your Vitest configuration: + +```ts +import { cloudflareTest } from "@cloudflare/vitest-pool-workers"; +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + plugins: [ + cloudflareTest({ + logLevel: "verbose", + }), + ], +}); +``` + +The default log level is `"info"`. See the [configuration reference](/workers/testing/vitest-integration/configuration/#cloudflaretestoptions) for all accepted values.