Skip to content
Open
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
14 changes: 7 additions & 7 deletions src/components/__tests__/Toaster.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ const ToasterTest = ({ toast = "This is a toast!" }: { toast?: Toast }) => {
};

beforeAll(() => {
Element.prototype.animate = vi
.fn()
.mockImplementation(() => ({ finished: Promise.resolve() }));

// Element.prototype.addEventListener = vi.fn().mockImplementation(() => {});
Element.prototype.animate = vi.fn().mockImplementation(() => ({
finished: Promise.resolve(),
addEventListener: vi.fn((type: string, callback: () => void) => callback()),
play: vi.fn(),
}))
});

afterAll(() => {
Expand All @@ -58,7 +58,7 @@ const sleep = (ms: number) => {
});
};

test.skip("Toast stays on screen for >= given duration", async () => {
test("Toast stays on screen for >= given duration", async () => {
const TOAST_WITH_CUSTOM_DURATION = {
duration: 1000,
content: "This is my second toast",
Expand All @@ -77,7 +77,7 @@ test.skip("Toast stays on screen for >= given duration", async () => {

await component.findByRole("alert");

await sleep(TOAST_WITH_CUSTOM_DURATION.duration / 2 + 200);
await sleep(TOAST_WITH_CUSTOM_DURATION.duration / 2);

const isThereAToast = component.queryByRole("alert");
expect(isThereAToast).toBeNull();
Expand Down
18 changes: 12 additions & 6 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
/// <reference types="vitest" />
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import react from '@vitejs/plugin-react';
import { defineConfig, UserConfig } from 'vite';
import type { InlineConfig } from 'vitest';

export default defineConfig({
interface VitestConfigExport extends UserConfig {
test: InlineConfig;
}

const vitestConfig: VitestConfigExport = {
plugins: [react()],
test: {
environment: "jsdom",
environment: 'jsdom',
globals: true,
},
});
};

export default defineConfig(vitestConfig);