Skip to content

Commit

Permalink
test: Fix requests to SocialDB
Browse files Browse the repository at this point in the history
  • Loading branch information
carina-akaia committed Jun 3, 2024
1 parent ab0d9c0 commit d5340bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/app/tests.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { screen, waitFor } from "@testing-library/react";
import { expect, test, vi } from "vitest";
import { expect, test } from "vitest";

import { renderWithStore } from "./_store/testEnv";
import Homepage from "./page";

// TODO: create separate testing env config and make its variables available globally for all tests
vi.stubEnv("NEXT_PUBLIC_NETWORK", "mainnet");
vi.stubEnv("NEXT_PUBLIC_SOCIAL_DB_CONTRACT_ID", "social.near");

renderWithStore(<Homepage />);

test("Homepage", async () => {
Expand All @@ -34,8 +30,13 @@ test("Homepage", async () => {
"project-card-fundraising-amount",
);

expect(
projectFundraisingAmounts.at(0)?.textContent,
"project fundraising amounts",
).toBeTruthy();
await waitFor(
() =>
expect(
projectFundraisingAmounts.at(0)?.textContent,
"project fundraising amounts",
).toBeTruthy(),

{ timeout: 2000 },
);
});
1 change: 1 addition & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import tsconfigPaths from "vite-tsconfig-paths";
import { defineConfig } from "vitest/config";

export default defineConfig({
envPrefix: "NEXT_PUBLIC_",
plugins: [tsconfigPaths(), react()],

test: {
Expand Down

0 comments on commit d5340bb

Please sign in to comment.