diff --git a/AGENTS.md b/AGENTS.md index 69e437d..8657979 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -262,7 +262,7 @@ Use data-driven testing across **all 5 routing universes**: ```typescript // Import the complete universe definitions -import { ROUTING_UNIVERSES } from "../testing/test-utils.js"; +import { ROUTING_UNIVERSES } from "$test/test-utils.js"; ROUTING_UNIVERSES.forEach((ru) => { describe(`Component - ${ru.text}`, () => { @@ -741,7 +741,7 @@ test("Should react to state changes.", () => { For testing components that rely on `window.location` and `window.history` (like `RouterEngine`), use the comprehensive browser mocking utilities: ```typescript -import { setupBrowserMocks } from "../testing/test-utils.js"; +import { setupBrowserMocks } from "$test/test-utils.js"; describe("Component requiring browser APIs", () => { beforeEach(() => { @@ -807,7 +807,7 @@ Refer to `src/testing/test-utils.ts` for complete function signatures and type d **Complete test coverage across all 5 routing universes** using the standardized pattern: ```typescript -import { ROUTING_UNIVERSES } from "../testing/test-utils.js"; +import { ROUTING_UNIVERSES } from "$test/test-utils.js"; // ✅ Recommended: Test ALL universes with single loop ROUTING_UNIVERSES.forEach((universe) => { @@ -856,7 +856,7 @@ Use dictionary-based constants for better maintainability: ```typescript // Import self-documenting hash values -import { ALL_HASHES } from "../testing/test-utils.js"; +import { ALL_HASHES } from "$test/test-utils.js"; // Usage in tests test("Should validate hash compatibility.", () => { diff --git a/src/lib/Fallback/Fallback.svelte.test.ts b/src/lib/Fallback/Fallback.svelte.test.ts index 4a1f226..2cf6952 100644 --- a/src/lib/Fallback/Fallback.svelte.test.ts +++ b/src/lib/Fallback/Fallback.svelte.test.ts @@ -2,7 +2,7 @@ import { init } from "$lib/init.js"; import { describe, test, expect, beforeAll, afterAll, beforeEach } from "vitest"; import { render } from "@testing-library/svelte"; import Fallback from "./Fallback.svelte"; -import { addMatchingRoute, addRoutes, createRouterTestSetup, createTestSnippet, ROUTING_UNIVERSES, ALL_HASHES } from "../../testing/test-utils.js"; +import { addMatchingRoute, addRoutes, createRouterTestSetup, createTestSnippet, ROUTING_UNIVERSES, ALL_HASHES } from "$test/test-utils.js"; import { flushSync } from "svelte"; import { resetRoutingOptions, setRoutingOptions } from "$lib/kernel/options.js"; import type { ExtendedRoutingOptions } from "$lib/types.js"; diff --git a/src/lib/Link/Link.svelte.test.ts b/src/lib/Link/Link.svelte.test.ts index 4631533..e1b98e2 100644 --- a/src/lib/Link/Link.svelte.test.ts +++ b/src/lib/Link/Link.svelte.test.ts @@ -3,7 +3,7 @@ import { location } from "$lib/kernel/Location.js"; import { describe, test, expect, beforeAll, afterAll, beforeEach, vi, afterEach } from "vitest"; import { render, fireEvent } from "@testing-library/svelte"; import Link from "./Link.svelte"; -import { createRouterTestSetup, createTestSnippet, ROUTING_UNIVERSES, ALL_HASHES, createWindowMock, setupBrowserMocks, type RoutingUniverse, addMatchingRoute } from "../../testing/test-utils.js"; +import { createRouterTestSetup, createTestSnippet, ROUTING_UNIVERSES, ALL_HASHES, createWindowMock, setupBrowserMocks, type RoutingUniverse, addMatchingRoute } from "$test/test-utils.js"; import { flushSync } from "svelte"; import { resetRoutingOptions, setRoutingOptions } from "$lib/kernel/options.js"; import type { ExtendedRoutingOptions } from "$lib/types.js"; diff --git a/src/lib/LinkContext/LinkContext.svelte.test.ts b/src/lib/LinkContext/LinkContext.svelte.test.ts index c85bc16..114e7e2 100644 --- a/src/lib/LinkContext/LinkContext.svelte.test.ts +++ b/src/lib/LinkContext/LinkContext.svelte.test.ts @@ -1,7 +1,7 @@ import { describe, test, expect, vi, afterEach } from "vitest"; import { render } from "@testing-library/svelte"; import { linkCtxKey, type ILinkContext } from "./LinkContext.svelte"; -import TestLinkContextWithContextSpy from "../../testing/TestLinkContextWithContextSpy.svelte"; +import TestLinkContextWithContextSpy from "$test/TestLinkContextWithContextSpy.svelte"; import { flushSync } from "svelte"; import type { ActiveStateAriaAttributes } from "$lib/types.js"; diff --git a/src/lib/Route/Route.svelte.test.ts b/src/lib/Route/Route.svelte.test.ts index 608fa45..f1fbc88 100644 --- a/src/lib/Route/Route.svelte.test.ts +++ b/src/lib/Route/Route.svelte.test.ts @@ -1,10 +1,10 @@ import { describe, test, expect, beforeEach, vi, beforeAll, afterAll, afterEach } from "vitest"; import { render } from "@testing-library/svelte"; import Route from "./Route.svelte"; -import { createTestSnippet, createRouterTestSetup, ROUTING_UNIVERSES, ALL_HASHES } from "../../testing/test-utils.js"; +import { createTestSnippet, createRouterTestSetup, ROUTING_UNIVERSES, ALL_HASHES } from "$test/test-utils.js"; import { init } from "$lib/init.js"; import { location } from "$lib/kernel/Location.js"; -import TestRouteWithRouter from "../../testing/TestRouteWithRouter.svelte"; +import TestRouteWithRouter from "$test/TestRouteWithRouter.svelte"; import { resetRoutingOptions, setRoutingOptions } from "$lib/kernel/options.js"; import type { ExtendedRoutingOptions, InitOptions } from "$lib/types.js"; diff --git a/src/lib/Router/Router.svelte.test.ts b/src/lib/Router/Router.svelte.test.ts index 7fd0f91..aba7219 100644 --- a/src/lib/Router/Router.svelte.test.ts +++ b/src/lib/Router/Router.svelte.test.ts @@ -2,7 +2,7 @@ import { describe, test, expect, beforeEach, vi, beforeAll, afterAll } from "vit import { render } from "@testing-library/svelte"; import Router, { getRouterContextKey } from "./Router.svelte"; import { RouterEngine } from "$lib/kernel/RouterEngine.svelte.js"; -import { createTestSnippet, createRouterTestSetup, ROUTING_UNIVERSES } from "../../testing/test-utils.js"; +import { createTestSnippet, createRouterTestSetup, ROUTING_UNIVERSES } from "$test/test-utils.js"; import { flushSync } from "svelte"; import { init } from "$lib/init.js"; diff --git a/src/lib/behaviors/active.svelte.test.ts b/src/lib/behaviors/active.svelte.test.ts index 3e69c68..67f9a95 100644 --- a/src/lib/behaviors/active.svelte.test.ts +++ b/src/lib/behaviors/active.svelte.test.ts @@ -3,7 +3,7 @@ import { activeBehavior } from "./active.svelte.js"; import { RouterEngine } from "$lib/kernel/RouterEngine.svelte.js"; import type { ActiveState, RouteStatus } from "$lib/types.js"; import { render } from "@testing-library/svelte"; -import TestActiveBehavior from "../../testing/TestActiveBehavior.svelte"; +import TestActiveBehavior from "$test/TestActiveBehavior.svelte"; import { flushSync } from "svelte"; import type { ClassValue } from "svelte/elements"; import { clsx } from "clsx"; diff --git a/src/lib/kernel/InterceptedHistoryApi.svelte.test.ts b/src/lib/kernel/InterceptedHistoryApi.svelte.test.ts index 3667eeb..f2b6dce 100644 --- a/src/lib/kernel/InterceptedHistoryApi.svelte.test.ts +++ b/src/lib/kernel/InterceptedHistoryApi.svelte.test.ts @@ -1,7 +1,7 @@ import { describe, test, expect, beforeEach, afterEach, vi } from "vitest"; import { InterceptedHistoryApi } from "./InterceptedHistoryApi.svelte.js"; import type { State, BeforeNavigateEvent } from "../types.js"; -import { setupBrowserMocks } from "../../testing/test-utils.js"; +import { setupBrowserMocks } from "$test/test-utils.js"; describe("InterceptedHistoryApi", () => { const initialUrl = "http://example.com/"; diff --git a/src/lib/kernel/LocationFull.test.ts b/src/lib/kernel/LocationFull.test.ts index f457dc9..bb563de 100644 --- a/src/lib/kernel/LocationFull.test.ts +++ b/src/lib/kernel/LocationFull.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; import { LocationFull } from "./LocationFull.js"; import type { State, Location, FullModeHistoryApi } from "../types.js"; -import { setupBrowserMocks, ALL_HASHES } from "../../testing/test-utils.js"; +import { setupBrowserMocks, ALL_HASHES } from "$test/test-utils.js"; import { SvelteURL } from "svelte/reactivity"; describe("LocationFull", () => { diff --git a/src/lib/kernel/LocationLite.svelte.test.ts b/src/lib/kernel/LocationLite.svelte.test.ts index 17b22f0..bb003b3 100644 --- a/src/lib/kernel/LocationLite.svelte.test.ts +++ b/src/lib/kernel/LocationLite.svelte.test.ts @@ -1,7 +1,7 @@ import { describe, test, expect, beforeEach, afterEach, vi } from "vitest"; import { LocationLite } from "./LocationLite.svelte.js"; import type { ExtendedRoutingOptions, Hash, HistoryApi, PreserveQuery } from "../types.js"; -import { setupBrowserMocks, ALL_HASHES } from "../../testing/test-utils.js"; +import { setupBrowserMocks, ALL_HASHES } from "$test/test-utils.js"; import { SvelteURL } from "svelte/reactivity"; import { setLocation } from "./Location.js"; import { resetRoutingOptions, setRoutingOptions } from "./options.js"; diff --git a/src/lib/kernel/RouterEngine.svelte.test.ts b/src/lib/kernel/RouterEngine.svelte.test.ts index 755a935..a7fc87a 100644 --- a/src/lib/kernel/RouterEngine.svelte.test.ts +++ b/src/lib/kernel/RouterEngine.svelte.test.ts @@ -4,7 +4,7 @@ import { init } from "../init.js"; import { registerRouter } from "./trace.svelte.js"; import { location } from "./Location.js"; import type { State, RouteInfo, ExtendedRoutingOptions } from "../types.js"; -import { setupBrowserMocks, addRoutes, ROUTING_UNIVERSES, ALL_HASHES } from "../../testing/test-utils.js"; +import { setupBrowserMocks, addRoutes, ROUTING_UNIVERSES, ALL_HASHES } from "$test/test-utils.js"; import { resetRoutingOptions, setRoutingOptions } from "./options.js"; describe("RouterEngine", () => { diff --git a/src/lib/kernel/StockHistoryApi.svelte.test.ts b/src/lib/kernel/StockHistoryApi.svelte.test.ts index 0105270..353c9af 100644 --- a/src/lib/kernel/StockHistoryApi.svelte.test.ts +++ b/src/lib/kernel/StockHistoryApi.svelte.test.ts @@ -1,6 +1,6 @@ import { describe, test, expect, beforeEach, afterEach, vi } from "vitest"; import { StockHistoryApi } from "./StockHistoryApi.svelte.js"; -import { setupBrowserMocks } from "../../testing/test-utils.js"; +import { setupBrowserMocks } from "$test/test-utils.js"; describe("StockHistoryApi", () => { const initialUrl = "http://example.com/"; diff --git a/src/lib/kernel/calculateHref.test.ts b/src/lib/kernel/calculateHref.test.ts index 3aada98..20ec1e7 100644 --- a/src/lib/kernel/calculateHref.test.ts +++ b/src/lib/kernel/calculateHref.test.ts @@ -2,7 +2,7 @@ import { describe, test, expect, beforeAll, afterAll, beforeEach } from "vitest" import { calculateHref, type CalculateHrefOptions } from "./calculateHref.js"; import { init } from "../init.js"; import { location } from "./Location.js"; -import { ROUTING_UNIVERSES, ALL_HASHES } from "../../testing/test-utils.js"; +import { ROUTING_UNIVERSES, ALL_HASHES } from "$test/test-utils.js"; describe("calculateHref", () => { describe("(...paths) Overload", () => { diff --git a/src/lib/kernel/calculateState.test.ts b/src/lib/kernel/calculateState.test.ts index 5220eba..0f37c4e 100644 --- a/src/lib/kernel/calculateState.test.ts +++ b/src/lib/kernel/calculateState.test.ts @@ -1,7 +1,7 @@ import { init } from '../init.js'; import { describe, test, expect, beforeAll, afterAll, beforeEach } from 'vitest'; import { calculateState } from './calculateState.js'; -import { ROUTING_UNIVERSES, ALL_HASHES, setupBrowserMocks } from '../../testing/test-utils.js'; +import { ROUTING_UNIVERSES, ALL_HASHES, setupBrowserMocks } from '$test/test-utils.js'; describe('calculateState', () => { describe('Clean Slate (no existing state)', () => { diff --git a/src/lib/utils.test.ts b/src/lib/utils.test.ts index c5e6566..6f77e2e 100644 --- a/src/lib/utils.test.ts +++ b/src/lib/utils.test.ts @@ -1,6 +1,6 @@ import { afterEach, describe, expect, test, vi } from "vitest"; import { assertAllowedRoutingMode, expandAriaAttributes } from "./utils.js"; -import { ALL_HASHES } from "../testing/test-utils.js"; +import { ALL_HASHES } from "$test/test-utils.js"; import { resetRoutingOptions, setRoutingOptions } from "./kernel/options.js"; import type { ActiveStateAriaAttributes, ExtendedRoutingOptions, Hash } from "./types.js"; import type { AriaAttributes } from "svelte/elements"; diff --git a/svelte.config.js b/svelte.config.js index 1295460..a12f872 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -11,7 +11,10 @@ const config = { // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. // If your environment is not supported, or you settled on a specific environment, switch out the adapter. // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter() + adapter: adapter(), + alias: { + $test: 'src/testing' + } } };