import { describe, expect, it } from "vitest"; import { unstable_doesMiddlewareMatch } from "next/experimental/testing/server"; import { config } from "./middleware"; // matcher-and-image-scope (F48): the middleware skips only Next internals and known static files. A page path that // merely contains a dot still goes through the route guard. const matches = (url: string) => unstable_doesMiddlewareMatch({ config, url }); describe("middleware matcher", () => { it.each(["/member/x.y", "/member/orders/a.b", "/login", "/", "/api/session", "/api/a.b"])("runs on %s", (url) => { expect(matches(url)).toBe(true); }); it.each([ "/_next/static/chunks/main.js", "/_next/image", "/favicon.ico", "/manifest.json", "/products/hero.webp", "/brands/logo.png", "/fonts/inter.woff2", "/robots.txt", "/sitemap.xml", ])("skips %s", (url) => { expect(matches(url)).toBe(false); }); });