Skip to content

Commit 4ffa0ef

Browse files
authored
Merge pull request #72 from pawcoding/copilot/upgrade-to-vitest-v4
Upgrade to Vitest v4
2 parents 577f53f + 3da8b2a commit 4ffa0ef

13 files changed

+239
-727
lines changed

package-lock.json

Lines changed: 143 additions & 682 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"@commitlint/cli": "20.1.0",
4747
"@commitlint/config-conventional": "20.0.0",
4848
"@types/node": "24.9.1",
49-
"@vitest/coverage-v8": "3.2.4",
49+
"@vitest/coverage-v8": "4.0.3",
5050
"astro": "5.15.1",
5151
"globals": "16.4.0",
5252
"husky": "9.1.7",
@@ -57,7 +57,7 @@
5757
"prettier-plugin-organize-imports": "4.3.0",
5858
"prettier-plugin-packagejson": "2.5.19",
5959
"typescript": "5.9.3",
60-
"vitest": "3.2.4"
60+
"vitest": "4.0.3"
6161
},
6262
"peerDependencies": {
6363
"astro": "^5.10.0"

test/loader/fetch-collection.e2e-spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
} from "astro/content/runtime";
55
import { randomUUID } from "crypto";
66
import {
7-
afterEach,
87
assert,
98
beforeAll,
109
beforeEach,
@@ -52,10 +51,6 @@ describe("fetchCollection", () => {
5251
superuserToken = token;
5352
});
5453

55-
afterEach(() => {
56-
vi.resetAllMocks();
57-
});
58-
5954
test("should fetch entries without errors", async () => {
6055
await fetchCollection(options, chunkLoadedMock, superuserToken, undefined);
6156

test/loader/live-collection-loader.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LiveCollectionError } from "astro/content/runtime";
2-
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2+
import { beforeEach, describe, expect, test, vi } from "vitest";
33
import { liveCollectionLoader } from "../../src/loader/live-collection-loader";
44
import { createLiveLoaderOptions } from "../_mocks/create-live-loader-options";
55
import { createPocketbaseEntry } from "../_mocks/create-pocketbase-entry";
@@ -16,10 +16,6 @@ describe("liveCollectionLoader", async () => {
1616
plem.parseLiveEntry = vi.fn().mockImplementation((e) => e);
1717
});
1818

19-
afterEach(() => {
20-
vi.resetAllMocks();
21-
});
22-
2319
test("should return live data collection with parsed entries", async () => {
2420
const entry = createPocketbaseEntry();
2521

test/loader/live-entry-loader.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LiveCollectionError } from "astro/content/runtime";
2-
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2+
import { beforeEach, describe, expect, test, vi } from "vitest";
33
import { liveEntryLoader } from "../../src/loader/live-entry-loader";
44
import { createLiveLoaderOptions } from "../_mocks/create-live-loader-options";
55
import { createPocketbaseEntry } from "../_mocks/create-pocketbase-entry";
@@ -16,10 +16,6 @@ describe("liveEntryLoader", async () => {
1616
plem.parseLiveEntry = vi.fn().mockImplementation((e) => e);
1717
});
1818

19-
afterEach(() => {
20-
vi.resetAllMocks();
21-
});
22-
2319
test("should return parsed entry", async () => {
2420
const entry = createPocketbaseEntry();
2521
fem.fetchEntry = vi.fn().mockResolvedValue(entry);

test/loader/load-entries.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { LoaderContext } from "astro/loaders";
2-
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2+
import { beforeEach, describe, expect, test, vi } from "vitest";
33
import { loadEntries } from "../../src/loader/load-entries";
44
import { createLoaderContext } from "../_mocks/create-loader-context";
55
import { createLoaderOptions } from "../_mocks/create-loader-options";
@@ -18,10 +18,6 @@ describe("loadEntries", async () => {
1818
context = createLoaderContext();
1919
});
2020

21-
afterEach(() => {
22-
vi.resetAllMocks();
23-
});
24-
2521
test("should call fetchCollection and parseEntry for each entry", async () => {
2622
const entry = createPocketbaseEntry();
2723

test/loader/loader.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { LoaderContext } from "astro/loaders";
2-
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2+
import { beforeEach, describe, expect, test, vi } from "vitest";
33
import packageJson from "../../package.json";
44
import { cleanupEntries } from "../../src/loader/cleanup-entries";
55
import { handleRealtimeUpdates } from "../../src/loader/handle-realtime-updates";
@@ -29,10 +29,6 @@ describe("loader", async () => {
2929
);
3030
});
3131

32-
afterEach(() => {
33-
vi.resetAllMocks();
34-
});
35-
3632
test('should not refresh if shouldRefresh returns "skip"', async () => {
3733
srm.shouldRefresh = vi.fn().mockReturnValue("skip");
3834

test/loader/parse-entry.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { LoaderContext } from "astro/loaders";
2-
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2+
import { beforeEach, describe, expect, test, vi } from "vitest";
33
import { parseEntry } from "../../src/loader/parse-entry";
44
import type { PocketBaseEntry } from "../../src/types/pocketbase-entry.type";
55
import { createLoaderContext } from "../_mocks/create-loader-context";
@@ -15,10 +15,6 @@ describe("parseEntry", () => {
1515
entry = createPocketbaseEntry();
1616
});
1717

18-
afterEach(() => {
19-
vi.resetAllMocks();
20-
});
21-
2218
test("should use default ID if no custom ID field is provided", async () => {
2319
const options = createLoaderOptions();
2420

test/schema/generate-schema.e2e-spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ZodObject, ZodSchema } from "astro/zod";
2-
import { afterEach, assert, beforeAll, describe, expect, it, vi } from "vitest";
2+
import { assert, beforeAll, describe, expect, it, vi } from "vitest";
33
import type { PocketBaseLoaderOptions } from "../../src";
44
import { generateSchema } from "../../src/schema/generate-schema";
55
import { transformFileUrl } from "../../src/schema/transform-files";
@@ -29,10 +29,6 @@ describe("generateSchema", () => {
2929
token = superuserToken;
3030
});
3131

32-
afterEach(() => {
33-
vi.resetAllMocks();
34-
});
35-
3632
describe("load and parse schema", () => {
3733
it("should return basic schema if no schema is available", async () => {
3834
const result = (await generateSchema(

test/schema/read-local-schema.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from "fs/promises";
22
import path from "path";
3-
import { beforeEach, describe, expect, test, vi } from "vitest";
3+
import { describe, expect, test, vi } from "vitest";
44
import { readLocalSchema } from "../../src/schema/read-local-schema";
55

66
vi.mock("fs/promises");
@@ -21,10 +21,6 @@ describe("readLocalSchema", () => {
2121
}
2222
];
2323

24-
beforeEach(() => {
25-
vi.clearAllMocks();
26-
});
27-
2824
test("should return the schema for the specified collection", async () => {
2925
vi.spyOn(path, "join").mockReturnValue(localSchemaPath);
3026
vi.spyOn(fs, "readFile").mockResolvedValue(JSON.stringify(mockSchema));

0 commit comments

Comments
 (0)