mirror of
https://github.com/morluto/rea.git
synced 2026-12-02 13:11:18 -05:00
test: require a matcher for every toThrow assertion (#15577)
A bare toThrow() or rejects.toThrow() passes on any error, including one from a broken fixture or a refusal for the wrong reason. The suite's 429 bare sites now assert the specific refusal, so turn on vitest/require-to-throw-message as an error to keep it that way. Tighten the one site added since (malformed TOML now asserts smol-toml's line and column). The two sites whose refusal cannot be observed outside Linux or without a native capture bound keep a bare matcher with a disable comment saying why.
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@
|
||||
"vitest/expect-expect": "off",
|
||||
"vitest/no-disabled-tests": "off",
|
||||
"vitest/require-mock-type-parameters": "off",
|
||||
"vitest/require-to-throw-message": "off",
|
||||
"vitest/require-to-throw-message": "error",
|
||||
"import/no-duplicates": [
|
||||
"warn",
|
||||
{
|
||||
|
||||
@@ -33,7 +33,10 @@ describe("parseClientToml", () => {
|
||||
});
|
||||
|
||||
it("rejects malformed TOML syntax", () => {
|
||||
expect(() => parseClientToml("[unterminated\nkey = 1\n")).toThrow();
|
||||
// smol-toml reports where the unterminated table header stops parsing.
|
||||
expect(() => parseClientToml("[unterminated\nkey = 1\n")).toThrow(
|
||||
expect.objectContaining({ line: 1, column: 14 }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ it.skipIf(process.platform !== "linux").each([false, true])(
|
||||
const selected = closeFault.handles.at(-1);
|
||||
if (selected === undefined) throw new Error("Missing database descriptor");
|
||||
first.allow();
|
||||
// oxlint-disable-next-line vitest/require-to-throw-message -- Linux-only fixture; its retry refusal has not been observed, and the lease state below is the asserted fact.
|
||||
await expect(failure.cleanupLease.release()).rejects.toThrow();
|
||||
expect(failure.cleanupLease.released).toBe(false);
|
||||
await expect(first.handle.stat()).rejects.toMatchObject({ code: "EBADF" });
|
||||
|
||||
@@ -781,6 +781,7 @@ it.skipIf(!hasNativeBound)(
|
||||
expect(result.error.cleanupIncomplete).toBe(true);
|
||||
|
||||
// Releasing only the snapshot leaves the primary cleanup failure open.
|
||||
// oxlint-disable-next-line vitest/require-to-throw-message -- needs a native capture bound to observe the refusal; the cleanup facts below are the asserted ones.
|
||||
await expect(provider.close()).rejects.toThrow();
|
||||
expect(result.error.cleanupResources).toEqual([resolvedCapinfos]);
|
||||
expect(result.error.cleanupIncomplete).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user