Skip to content

Commit cadb266

Browse files
committed
update vitest to 3.1.2, fix up some tests
1 parent 1938835 commit cadb266

File tree

4 files changed

+227
-166
lines changed

4 files changed

+227
-166
lines changed

integration-test/vitest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
"@types/react-dom": "*",
2121
"@vitejs/plugin-react": "^4.2.1",
2222
"graphql": "*",
23-
"vitest": "^1.3.1"
23+
"vitest": "^3.1.2"
2424
}
2525
}

integration-test/vitest/src/App.test.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { render, screen } from "@testing-library/react";
1+
import { act, render, screen } from "@testing-library/react";
22
import userEvent from "@testing-library/user-event";
33

44
import App from "./App";
@@ -7,7 +7,9 @@ import { resetApolloClientSingletons } from "@apollo/client-integration-nextjs";
77
afterEach(resetApolloClientSingletons);
88

99
test("loads data", async () => {
10-
render(<App />);
10+
await act(() => {
11+
render(<App />);
12+
});
1113

1214
expect(screen.getByText("Loading...")).toBeInTheDocument();
1315
expect(
@@ -17,7 +19,9 @@ test("loads data", async () => {
1719
});
1820

1921
test("is interactive", async () => {
20-
render(<App />);
22+
await act(() => {
23+
render(<App />);
24+
});
2125

2226
const counter = await screen.findByTestId("counter");
2327
expect(counter.textContent).toBe("0");

integration-test/vitest/src/hooks.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ test("will set up the data transport", () => {
6666
expect(globalThis[Symbol.for("ApolloClientSingleton")]).toBeDefined();
6767
});
6868

69-
test("resetNextSSRApolloSingletons tears down global singletons", () => {
69+
test("resetApolloClientSingletons tears down global singletons", () => {
7070
render(<></>, { wrapper });
7171
// wrappers are now set up, see last test
7272
// usually, we do this in `afterEach`
73-
resetNextSSRApolloSingletons();
73+
resetApolloClientSingletons();
7474
expect(globalThis[Symbol.for("ApolloSSRDataTransport")]).not.toBeDefined();
7575
expect(globalThis[Symbol.for("ApolloClientSingleton")]).not.toBeDefined();
7676
});

0 commit comments

Comments
 (0)