Fix and update tests
CI Pipeline / test (20) (pull_request) Failing after 2m41s
CI Pipeline / test (18) (pull_request) Failing after 4m30s
CI Pipeline / e2e (firefox) (pull_request) Successful in 3m17s
CI Pipeline / e2e (webkit) (pull_request) Successful in 3m40s
CI Pipeline / e2e (chromium) (pull_request) Successful in 11m13s
CI Pipeline / visual-regression (pull_request) Successful in 6m7s
CI Pipeline / performance (pull_request) Failing after 3m40s
CI Pipeline / storybook (pull_request) Successful in 1m14s
CI Pipeline / build (pull_request) Successful in 1m37s
CI Pipeline / test (20) (pull_request) Failing after 2m41s
CI Pipeline / test (18) (pull_request) Failing after 4m30s
CI Pipeline / e2e (firefox) (pull_request) Successful in 3m17s
CI Pipeline / e2e (webkit) (pull_request) Successful in 3m40s
CI Pipeline / e2e (chromium) (pull_request) Successful in 11m13s
CI Pipeline / visual-regression (pull_request) Successful in 6m7s
CI Pipeline / performance (pull_request) Failing after 3m40s
CI Pipeline / storybook (pull_request) Successful in 1m14s
CI Pipeline / build (pull_request) Successful in 1m37s
This commit is contained in:
+36
-1
@@ -1,5 +1,5 @@
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { afterAll, afterEach, beforeAll } from "vitest";
|
||||
import { afterAll, afterEach, beforeAll, vi } from "vitest";
|
||||
import { cleanup } from "@testing-library/react";
|
||||
import { server } from "./tests/msw/server";
|
||||
// Note: Tailwind CSS v4 uses syntax that jsdom can't parse
|
||||
@@ -7,6 +7,41 @@ import { server } from "./tests/msw/server";
|
||||
// Design tokens are accessible via CSS variables in the DOM
|
||||
// If you need to test CSS, use a CSS transformer or mock the import
|
||||
|
||||
// Mock next/dynamic for tests - return components directly instead of lazy loading
|
||||
vi.mock("next/dynamic", () => {
|
||||
const React = require("react");
|
||||
return {
|
||||
default: (importFn: () => Promise<any>, options?: any) => {
|
||||
// In tests, return a component that immediately resolves and renders
|
||||
return function DynamicComponent(props: any) {
|
||||
const [Component, setComponent] = React.useState(null);
|
||||
const [loading, setLoading] = React.useState(true);
|
||||
|
||||
React.useEffect(() => {
|
||||
importFn()
|
||||
.then((mod: any) => {
|
||||
setComponent(mod.default || mod);
|
||||
setLoading(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (loading && options?.loading) {
|
||||
return options.loading();
|
||||
}
|
||||
|
||||
if (Component) {
|
||||
return React.createElement(Component, props);
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
// MSW for API integration tests (mock fetch)
|
||||
beforeAll(() => server.listen({ onUnhandledRequest: "bypass" }));
|
||||
afterEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user