diff --git a/.prettierignore b/.prettierignore index 4d6b07d096df..05eb3491d700 100644 --- a/.prettierignore +++ b/.prettierignore @@ -37,3 +37,4 @@ fixtures/**/dist/** # Miniflare shouldn't be formatted with the root `prettier` version packages/miniflare +packages/vitest-pool-workers diff --git a/package.json b/package.json index 5505d5ff35f7..a0f5299ce074 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "fix": "pnpm run prettify && dotenv -- turbo check:lint -- --fix", "prettify": "prettier . --write --ignore-unknown", "test": "dotenv -- turbo test", - "test:ci": "vitest run && dotenv -- turbo test:ci --filter=wrangler --filter=miniflare", + "test:ci": "vitest run && dotenv -- turbo test:ci --filter=wrangler --filter=miniflare --filter=@cloudflare/vitest-pool-workers", "test:watch": "turbo test:watch", "type:tests": "dotenv -- turbo type:tests", "gen:package": "turbo gen package" diff --git a/packages/vitest-pool-workers/package.json b/packages/vitest-pool-workers/package.json index 3464bfa9a66b..96ba9d15e34f 100644 --- a/packages/vitest-pool-workers/package.json +++ b/packages/vitest-pool-workers/package.json @@ -16,7 +16,7 @@ "check:lint": "eslint .", "check:type": "tsc && tsc -p src/worker/tsconfig.json && tsc -p test/tsconfig.json", "test": "vitest --config vitest.workers.config.ts --reporter=basic", - "test:ci": "vitest --config vitest.workers.config.ts --reporter=basic" + "test:ci": "vitest run --config vitest.workers.config.ts --reporter=basic" }, "devDependencies": { "@cloudflare/eslint-config-worker": "workspace:*", @@ -38,5 +38,8 @@ "@vitest/runner": "1.1.3", "@vitest/snapshot": "1.1.3", "vitest": "1.1.3" + }, + "workers-sdk": { + "prerelease": true } } diff --git a/packages/vitest-pool-workers/src/pool/config.ts b/packages/vitest-pool-workers/src/pool/config.ts index 14c3d3eb4762..c1773d9d1a6b 100644 --- a/packages/vitest-pool-workers/src/pool/config.ts +++ b/packages/vitest-pool-workers/src/pool/config.ts @@ -1,6 +1,10 @@ import path from "node:path"; -import { PLUGINS } from "miniflare"; -import { formatZodError, getRootPath, parseWithRootPath } from "miniflare"; +import { + formatZodError, + getRootPath, + parseWithRootPath, + PLUGINS, +} from "miniflare"; import { z } from "zod"; import type { Awaitable, WorkerOptions } from "miniflare"; import type { ProvidedContext } from "vitest"; @@ -17,6 +21,7 @@ const WorkersPoolOptionsSchema = z.object({ isolatedStorage: z.boolean().default(false), singleWorker: z.boolean().default(false), setupEnvironment: z + // eslint-disable-next-line unused-imports/no-unused-vars .custom<(env: CloudflareTestEnv) => Awaitable>( (v) => typeof v === "function" ) diff --git a/packages/vitest-pool-workers/test/basic/setup/setup.ts b/packages/vitest-pool-workers/test/basic/setup/setup.ts index 8e19fc395b02..0e02c2471329 100644 --- a/packages/vitest-pool-workers/test/basic/setup/setup.ts +++ b/packages/vitest-pool-workers/test/basic/setup/setup.ts @@ -1,2 +1,4 @@ // Runs inside workerd // console.log("test setup from", navigator.userAgent); + +export {}; diff --git a/packages/vitest-pool-workers/turbo.json b/packages/vitest-pool-workers/turbo.json new file mode 100644 index 000000000000..1a6c74c9def8 --- /dev/null +++ b/packages/vitest-pool-workers/turbo.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://turbo.build/schema.json", + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["dist/**"] + } + } +} diff --git a/turbo.json b/turbo.json index 4a2025de8889..4c2d789b840c 100644 --- a/turbo.json +++ b/turbo.json @@ -13,6 +13,10 @@ "persistent": true, "cache": false }, + "@cloudflare/vitest-pool-workers#dev": { + "persistent": true, + "cache": false + }, "build": { "dependsOn": ["^build"] }, "test": { "dependsOn": ["^build"],