Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fixtures/additional-modules/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("find_additional_modules dev", () => {
await fs.rm(path.join(srcDir, "lang", "en.js"));

await vi.waitFor(async () => {
await expect(get(worker, "/lang/en")).rejects.toThrowError(
await expect(get(worker, "/lang/en")).rejects.toThrow(
'No such module "lang/en.js".'
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,31 @@ describe("getPlatformProxy - caches", () => {

expect(() => {
caches.has("my-cache");
}).toThrowError(
}).toThrow(
"Failed to execute 'has' on 'CacheStorage': the method is not implemented."
);

expect(() => {
caches.delete("my-cache");
}).toThrowError(
}).toThrow(
"Failed to execute 'delete' on 'CacheStorage': the method is not implemented."
);

expect(() => {
caches.keys();
}).toThrowError(
}).toThrow(
"Failed to execute 'keys' on 'CacheStorage': the method is not implemented."
);

expect(() => {
caches.match(new URL("https://localhost"));
}).toThrowError(
}).toThrow(
"Failed to execute 'match' on 'CacheStorage': the method is not implemented."
);

expect(() => {
caches.nonExistentMethod();
}).toThrowError("caches.nonExistentMethod is not a function");
}).toThrow("caches.nonExistentMethod is not a function");
} finally {
await dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ describe("getPlatformProxy - cf", () => {

expect(() => {
cf.city = "test city";
}).toThrowError(
}).toThrow(
"Cannot assign to read only property 'city' of object '#<Object>'"
);
expect(cf.city).not.toBe("test city");

expect(() => {
cf.newField = "test new field";
}).toThrowError("Cannot add property newField, object is not extensible");
}).toThrow("Cannot add property newField, object is not extensible");
expect("newField" in cf).toBe(false);

expect(cf.botManagement).toMatchObject({
Expand Down
20 changes: 10 additions & 10 deletions fixtures/get-platform-proxy/tests/get-platform-proxy.ctx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ describe("getPlatformProxy - ctx", () => {
try {
expect(() => {
waitUntil(new Promise(() => {}));
}).toThrowError("Illegal invocation");
}).toThrow("Illegal invocation");

expect(() => {
passThroughOnException();
}).toThrowError("Illegal invocation");
}).toThrow("Illegal invocation");
} finally {
await dispose();
}
Expand All @@ -87,11 +87,11 @@ describe("getPlatformProxy - ctx", () => {
try {
expect(() => {
waitUntil(new Promise(() => {}));
}).toThrowError("Illegal invocation");
}).toThrow("Illegal invocation");

expect(() => {
passThroughOnException();
}).toThrowError("Illegal invocation");
}).toThrow("Illegal invocation");
} finally {
await dispose();
}
Expand All @@ -107,15 +107,15 @@ describe("getPlatformProxy - ctx", () => {
try {
expect(() => {
waitUntil(new Promise(() => {}));
}).not.toThrowError("Illegal invocation");
}).not.toThrow("Illegal invocation");

expect(() => {
passThroughOnException.apply(ctx, []);
}).not.toThrowError("Illegal invocation");
}).not.toThrow("Illegal invocation");

expect(() => {
passThroughOnException.call(ctx);
}).not.toThrowError("Illegal invocation");
}).not.toThrow("Illegal invocation");
} finally {
await dispose();
}
Expand All @@ -131,15 +131,15 @@ describe("getPlatformProxy - ctx", () => {
try {
expect(() => {
waitUntil(new Promise(() => {}));
}).toThrowError("Illegal invocation");
}).toThrow("Illegal invocation");

expect(() => {
passThroughOnException.apply(5, []);
}).toThrowError("Illegal invocation");
}).toThrow("Illegal invocation");

expect(() => {
passThroughOnException.call(new Boolean());
}).toThrowError("Illegal invocation");
}).toThrow("Illegal invocation");
} finally {
await dispose();
}
Expand Down
4 changes: 2 additions & 2 deletions fixtures/pages-workerjs-app/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("Pages _worker.js", () => {
cwd: path.resolve(__dirname, ".."),
stdio: "ignore",
})
).toThrowError();
).toThrow();
});

it("should throw an error when the _worker.js file imports something and --no-bundle is true", ({
Expand All @@ -26,7 +26,7 @@ describe("Pages _worker.js", () => {
cwd: path.resolve(__dirname, ".."),
stdio: "ignore",
})
).toThrowError();
).toThrow();
});

it("should not throw an error when the _worker.js file imports something if --no-bundle is false", async ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ describe("detectFramework() / multiple frameworks detected", () => {
"package-lock.json": JSON.stringify({ lockfileVersion: 3 }),
});

await expect(
detectFramework(process.cwd(), ciContext)
).rejects.toThrowError(
await expect(detectFramework(process.cwd(), ciContext)).rejects.toThrow(
/Cloudflare's tooling was unable to automatically configure your project, since multiple frameworks were found/
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ describe("autoconfig details - getDetailsForAutoConfig()", () => {

await expect(
details.getDetailsForAutoConfig({ context: ciContext })
).rejects.toThrowError(
).rejects.toThrow(
/Cloudflare's tooling was unable to automatically configure your project, since multiple frameworks were found/
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/autoconfig/tests/vite-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export default defineConfig({
`
);

expect(() => transformViteConfig(".")).toThrowError(
expect(() => transformViteConfig(".")).toThrow(
/Cannot modify Vite config: could not find a valid plugins array/
);
});
Expand All @@ -279,7 +279,7 @@ export default defineConfig(() => ({
`
);

expect(() => transformViteConfig(".")).toThrowError(
expect(() => transformViteConfig(".")).toThrow(
/Cannot modify Vite config: could not find a valid plugins array/
);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/containers-shared/tests/images.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe("getAndValidateRegistryType - GAR", () => {
];
for (const domain of invalidGarDomains) {
it(`rejects ${domain}`, ({ expect }) => {
expect(() => getAndValidateRegistryType(domain)).toThrowError(
expect(() => getAndValidateRegistryType(domain)).toThrow(
`${domain} is not a supported image registry`
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("retry", () => {
await retry({ times: 3 }, async () => {
throw Error("testing");
});
}).rejects.toThrowError("testing");
}).rejects.toThrow("testing");
});

test("exit condition encountered", async ({ expect }) => {
Expand All @@ -65,6 +65,6 @@ describe("retry", () => {
throw Error("special condition");
}
);
}).rejects.toThrowError("special condition");
}).rejects.toThrow("special condition");
});
});
2 changes: 1 addition & 1 deletion packages/kv-asset-handler/test/getAssetFromKV.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test("getAssetFromKV if no asset manifest /client -> client fails", async ({
const event = getEvent(new Request(`https://foo.com/client`));
await expect(() =>
getAssetFromKV(event, { ASSET_MANIFEST: {} })
).rejects.toThrowError(expect.objectContaining({ status: 404 }));
).rejects.toThrow(expect.objectContaining({ status: 404 }));
});

test("getAssetFromKV if sub/ -> sub/index.html served", async ({ expect }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("quoteForDotenv", () => {

test("throws when a value cannot be losslessly serialized", ({ expect }) => {
// Contains all three quote characters — no safe encoding under dotenv.
expect(() => quoteForDotenv("'`\"")).toThrowError(
expect(() => quoteForDotenv("'`\"")).toThrow(
/Unable to serialize value to \.dev\.vars/
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe("resolveWorkerType", () => {
);
expect(() =>
resolveWorkerType(config, raw, nonApplicable, { configPath })
).toThrowError(
).toThrow(
/The provided Wrangler config main field \(.*?index\.ts\) doesn't point to an existing file/
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe("FlagAssertions", () => {
enableFlag: "enable-flag",
defaultOnDate: "invalid-date",
});
}).toThrowError('Invalid date format: "invalid-date"');
}).toThrow('Invalid date format: "invalid-date"');
});

it("throws error when compatibilityDate is invalid", ({ expect }) => {
Expand All @@ -161,7 +161,7 @@ describe("FlagAssertions", () => {
enableFlag: "enable-flag",
defaultOnDate: "2023-01-01",
});
}).toThrowError('Invalid date format: "invalid-date"');
}).toThrow('Invalid date format: "invalid-date"');
});
});

Expand Down
8 changes: 4 additions & 4 deletions packages/workers-shared/asset-worker/tests/kv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("[Asset Worker] Fetching assets from KV", () => {

await expect(() =>
getAssetWithMetadataFromKV(mockKVNamespace, "abcd")
).rejects.toThrowError("KV GET abcd failed.");
).rejects.toThrow("KV GET abcd failed.");
});

it("should retry once by default if something went wrong while fetching the asset", async ({
Expand All @@ -60,7 +60,7 @@ describe("[Asset Worker] Fetching assets from KV", () => {

await expect(() =>
getAssetWithMetadataFromKV(mockKVNamespace, "abcd")
).rejects.toThrowError("KV GET abcd failed.");
).rejects.toThrow("KV GET abcd failed.");
expect(spy).toHaveBeenCalledTimes(2);
});

Expand All @@ -69,7 +69,7 @@ describe("[Asset Worker] Fetching assets from KV", () => {

await expect(() =>
getAssetWithMetadataFromKV(mockKVNamespace, "abcd", undefined, 2)
).rejects.toThrowError("KV GET abcd failed.");
).rejects.toThrow("KV GET abcd failed.");
expect(spy).toHaveBeenCalledTimes(3);
});

Expand All @@ -80,7 +80,7 @@ describe("[Asset Worker] Fetching assets from KV", () => {

await expect(() =>
getAssetWithMetadataFromKV(mockKVNamespace, "abcd")
).rejects.toThrowError("KV GET abcd failed: Oeps! Something went wrong");
).rejects.toThrow("KV GET abcd failed: Oeps! Something went wrong");
expect(spy).toHaveBeenCalledTimes(2);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("inner entrypoint unit tests", () => {

await expect(
async () => await fetchFromInnerEntrypoint(request, env, ctx)
).rejects.toThrowError(
).rejects.toThrow(
"Fetch for user worker without having a user worker binding"
);
});
Expand Down
4 changes: 1 addition & 3 deletions packages/workers-utils/tests/prometheus-metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ describe("MetricsRegistry", () => {
it("throws on negative values", ({ expect }) => {
const registry = new MetricsRegistry();
const counter = registry.createCounter("test_total", "A test counter");
expect(() => counter.add(-1)).toThrowError(
"Counter value cannot decrease"
);
expect(() => counter.add(-1)).toThrow("Counter value cannot decrease");
});

it("can be combined with inc", ({ expect }) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/wrangler/e2e/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ describe("custom builds", () => {
// regression: https://github.com/cloudflare/workers-sdk/issues/6876
await expect(
worker.readUntil(/\[custom build\] Running/, 5_000)
).rejects.toThrowError();
).rejects.toThrow();

// now check assets are still fetchable, even after updates

Expand Down Expand Up @@ -2085,7 +2085,7 @@ describe("watch mode", () => {
await worker.waitForReload();

// The three changes should be debounced, so only one reload should occur
await expect(worker.waitForReload(5_000)).rejects.toThrowError();
await expect(worker.waitForReload(5_000)).rejects.toThrow();

// now check assets are still fetchable
await expect(fetchText(url)).resolves.toBe("Hello from Assets");
Expand Down
12 changes: 5 additions & 7 deletions packages/wrangler/e2e/startWorker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ describe("DevEnv", { sequential: true }, () => {
undiciRes = await undici.fetch(`http://127.0.0.1:${newPort}`);
await expect(undiciRes.text()).resolves.toBe("body:1");

await expect(
undici.fetch(`http://127.0.0.1:${oldPort}`)
).rejects.toThrowError("fetch failed");
await expect(undici.fetch(`http://127.0.0.1:${oldPort}`)).rejects.toThrow(
"fetch failed"
);
});

it("liveReload", async ({ expect }) => {
Expand Down Expand Up @@ -456,7 +456,7 @@ describe("DevEnv", { sequential: true }, () => {
});
onTestFinished(worker?.dispose);

await expect(worker.fetch("http://dummy")).rejects.toThrowError("Boom!");
await expect(worker.fetch("http://dummy")).rejects.toThrow("Boom!");

await helper.seed({
"src/index.ts": dedent`
Expand All @@ -469,9 +469,7 @@ describe("DevEnv", { sequential: true }, () => {
});

await waitFor(async () => {
await expect(worker.fetch("http://dummy")).rejects.toThrowError(
"Boom 2!"
);
await expect(worker.fetch("http://dummy")).rejects.toThrow("Boom 2!");
});

// test eyeball requests receive the pretty error page
Expand Down
Loading
Loading