Skip to content

Commit

Permalink
Integrate vitest-pool-workers with monorepo tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbbot committed Jan 23, 2024
1 parent febfef7 commit 1038bee
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ fixtures/**/dist/**

# Miniflare shouldn't be formatted with the root `prettier` version
packages/miniflare
packages/vitest-pool-workers
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion packages/vitest-pool-workers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand All @@ -38,5 +38,8 @@
"@vitest/runner": "1.1.3",
"@vitest/snapshot": "1.1.3",
"vitest": "1.1.3"
},
"workers-sdk": {
"prerelease": true
}
}
9 changes: 7 additions & 2 deletions packages/vitest-pool-workers/src/pool/config.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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<void>>(
(v) => typeof v === "function"
)
Expand Down
2 changes: 2 additions & 0 deletions packages/vitest-pool-workers/test/basic/setup/setup.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
// Runs inside workerd
// console.log("test setup from", navigator.userAgent);

export {};
9 changes: 9 additions & 0 deletions packages/vitest-pool-workers/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "http://turbo.build/schema.json",
"extends": ["//"],
"pipeline": {
"build": {
"outputs": ["dist/**"]
}
}
}
4 changes: 4 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"persistent": true,
"cache": false
},
"@cloudflare/vitest-pool-workers#dev": {
"persistent": true,
"cache": false
},
"build": { "dependsOn": ["^build"] },
"test": {
"dependsOn": ["^build"],
Expand Down

0 comments on commit 1038bee

Please sign in to comment.