Skip to content

Commit

Permalink
Format with monorepo's prettier version
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbbot committed Feb 16, 2024
1 parent 40384a8 commit d8be18e
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 23 deletions.
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ fixtures/**/dist/**

# Miniflare shouldn't be formatted with the root `prettier` version
packages/miniflare
packages/vitest-pool-workers

# Generated Cap'n Proto files shouldn't be formatted
*.capnp.js
*.capnp.d.ts

# In the C3 templates, in particular framework templates, we want to be able to
# use any format that the framework authors prefer/use in their own templates,
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest-pool-workers/src/pool/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
PLUGINS,
} from "miniflare";
import { z } from "zod";
import { getProjectPath, getRelativeProjectPath } from "./helpers";
import type { WorkerOptions } from "miniflare";
import type { ProvidedContext } from "vitest";
import type { WorkspaceProject } from "vitest/node";
import type { ParseParams, ZodError } from "zod";
import { getProjectPath, getRelativeProjectPath } from "./helpers";

const PLUGIN_VALUES = Object.values(PLUGINS);

Expand Down
8 changes: 4 additions & 4 deletions packages/vitest-pool-workers/src/pool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import util from "node:util";
import { createBirpc } from "birpc";
import * as devalue from "devalue";
import {
kCurrentWorker,
kUnsafeEphemeralUniqueKey,
Log,
LogLevel,
Miniflare,
structuredSerializableReducers,
structuredSerializableRevivers,
WebSocket,
kCurrentWorker,
kUnsafeEphemeralUniqueKey,
} from "miniflare";
import { createMethodsRPC } from "vitest/node";
import { OPTIONS_PATH, parseProjectOptions } from "./config";
Expand All @@ -35,10 +35,10 @@ import {
ensurePosixLikePath,
handleModuleFallbackRequest,
} from "./module-fallback";
import type { WorkersPoolOptions, SourcelessWorkerOptions } from "./config";
import type { SourcelessWorkerOptions, WorkersPoolOptions } from "./config";
import type { CloseEvent, MiniflareOptions, WorkerOptions } from "miniflare";
import type { MessagePort } from "node:worker_threads";
import type { Readable } from "node:stream";
import type { MessagePort } from "node:worker_threads";
import type {
ResolvedConfig,
RunnerRPC,
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest-pool-workers/src/worker/durable-objects.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from "node:assert";
import { internalEnv, getSerializedOptions } from "./env";
import { getSerializedOptions, internalEnv } from "./env";
import { importModule, mustGetResolvedMainPath } from "./import";

const CF_KEY_ACTION = "vitestPoolWorkersDurableObjectAction";
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest-pool-workers/src/worker/fetch-mock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert";
import { Buffer } from "node:buffer";
import { MockAgent, setDispatcher, isMockActive } from "cloudflare:mock-agent";
import { isMockActive, MockAgent, setDispatcher } from "cloudflare:mock-agent";
import type { Dispatcher } from "undici";

// See public facing `cloudflare:test` types for docs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import assert from "node:assert";
import { NodeSnapshotEnvironment } from "@vitest/snapshot/environment";
import { resetMockAgent } from "cloudflare:mock-agent";
import {
internalEnv,
fetchMock,
getSerializedOptions,
internalEnv,
} from "cloudflare:test-internal";
import { VitestTestRunner } from "vitest/runners";
import workerdUnsafe from "workerd:unsafe";
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest-pool-workers/src/worker/lib/node/tty.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function isatty() {
return false;
return false;
}
2 changes: 1 addition & 1 deletion packages/vitest-pool-workers/test/basic/fake-timer.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

describe("fake timers", () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest-pool-workers/test/basic/maths.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect, inject } from "vitest";
import { describe, expect, inject, it } from "vitest";

describe("maths", () => {
it("adds", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest-pool-workers/test/basic/mocking.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// import { fetch as undiciFetch } from "undici";
import { describe, it, expect, afterEach, vi } from "vitest";
import { afterEach, describe, expect, it, vi } from "vitest";

afterEach(() => {
vi.restoreAllMocks();
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest-pool-workers/test/basic/strings.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect } from "vitest";
import { describe, expect, it } from "vitest";

describe("strings", () => {
it("concatenates", () => {
Expand Down
15 changes: 9 additions & 6 deletions packages/vitest-pool-workers/test/kv/store.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
createExecutionContext,
env,
SELF,
fetchMock,
runInDurableObject,
runDurableObjectAlarm,
listDurableObjectIds,
createExecutionContext,
runDurableObjectAlarm,
runInDurableObject,
SELF,
waitOnExecutionContext,
} from "cloudflare:test";
import { describe, it, expect, afterAll, beforeAll } from "vitest";
import worker, { transformResponse, Counter } from "./worker";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import worker, { Counter, transformResponse } from "./worker";

beforeAll(() => {
fetchMock.activate();
Expand Down Expand Up @@ -112,6 +112,9 @@ describe("kv", () => {
"http://localhost"
);
const ctx = createExecutionContext();
// @ts-expect-error `fetch()` is defined, but optional on `ExportedHandler`.
// The solution is to use `satisfies ExportedHandler` here instead, but
// we're stuck on an old TypeScript version until we bump to Prettier 3.
const response = await worker.fetch(request, env, ctx);
await waitOnExecutionContext(ctx);
expect(await response.text()).toBe("body:http://localhost");
Expand Down
7 changes: 5 additions & 2 deletions packages/vitest-pool-workers/test/kv/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ export function transformResponse(response: Response): Response {
.transform(response);
}

export default {
// TODO(soon): once we upgrade to TypeScript 5/Prettier 3, replace this with
// `satisfies ExportedHandler<Env>` so we don't need non-null assertions on
// the `fetch()` method
export default <ExportedHandler<Env>>{
async fetch(request, _env, _ctx) {
return new Response(`body:${request.url}`);
},
} satisfies ExportedHandler<Env>;
};
2 changes: 1 addition & 1 deletion packages/vitest-pool-workers/test/stacked/stacked.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { env } from "cloudflare:test";
import { describe, beforeAll, beforeEach, expect, test } from "vitest";
import { beforeAll, beforeEach, describe, expect, test } from "vitest";

async function get() {
return await env.TEST_NAMESPACE.get("thing");
Expand Down

0 comments on commit d8be18e

Please sign in to comment.