Repository: denoland/fresh
File: tests/test_utils.tsx (TypeScript)

Code before:
import { expect } from "@std/expect";
import { ProdBuildCache } from "../src/build_cache.ts";
import { Counter } from "./fixtures_islands/Counter.tsx";
import { CounterWithSlots } from "./fixtures_islands/CounterWithSlots.tsx";
import { EscapeIsland } from "./fixtures_islands/EscapeIsland.tsx";
import { FnIsland } from "./fixtures_islands/FnIsland.tsx";
import { FragmentIsland } from "./fixtures_islands/FragmentIsland.tsx";
import { IslandInIsland } from "./fixtures_islands/IslandInIsland.tsx";
import { JsonIsland } from "./fixtures_islands/JsonIsland.tsx";
import { JsxChildrenIsland } from "./fixtures_islands/JsxChildrenIsland.tsx";
import { JsxConditional } from "./fixtures_islands/JsxConditional.tsx";
import { JsxIsland } from "./fixtures_islands/JsxIsland.tsx";
import { NullIsland } from "./fixtures_islands/NullIsland.tsx";
import { PartialInIsland } from "./fixtures_islands/PartialInIsland.tsx";
import { PassThrough } from "./fixtures_islands/PassThrough.tsx";
import { SelfCounter } from "./fixtures_islands/SelfCounter.tsx";
import { Multiple1, Multiple2 } from "./fixtures_islands/Multiple.tsx";
import { Foo } from "./fixture_island_groups/routes/foo/(_islands)/Foo.tsx";
import { NodeProcess } from "./fixtures_islands/NodeProcess.tsx";
import { FreshAttrs } from "./fixtures_islands/FreshAttrs.tsx";
import { OptOutPartialLink } from "./fixtures_islands/OptOutPartialLink.tsx";

/**
 * If on Linux, disable `AppArmor` before running tests:
 * ```sh
 * echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
 * ```
 *
 * @see {@link https://github.com/lino-levan/astral#no-usable-sandbox-with-user-namespace-cloning-enabled}
 */
const browser = await launch({
  args: ["--window-size=1280,720"],
  headless: true,
});

addEventListener("unload", async () => {
  await browser.close();
});

export function getIsland(pathname: string) {
  return path.join(
    import.meta.dirname!,
    "fixtures_islands",
    pathname,
  );
}

export const charset = <meta charset="utf-8" />;

export const favicon = (
  <link

Review comment (security):
I'm not sure if it's a good idea to tell contributors on Linux to disable `AppArmor` globally on their machines. Contributing to a JS framework shouldn't come with the requirements to disable central security features in the OS you're using.

Code after:
import { expect } from "@std/expect";
import { ProdBuildCache } from "../src/build_cache.ts";
import { Counter } from "./fixtures_islands/Counter.tsx";
import { CounterWithSlots } from "./fixtures_islands/CounterWithSlots.tsx";
import { EscapeIsland } from "./fixtures_islands/EscapeIsland.tsx";
import { FnIsland } from "./fixtures_islands/FnIsland.tsx";
import { FragmentIsland } from "./fixtures_islands/FragmentIsland.tsx";
import { IslandInIsland } from "./fixtures_islands/IslandInIsland.tsx";
import { JsonIsland } from "./fixtures_islands/JsonIsland.tsx";
import { JsxChildrenIsland } from "./fixtures_islands/JsxChildrenIsland.tsx";
import { JsxConditional } from "./fixtures_islands/JsxConditional.tsx";
import { JsxIsland } from "./fixtures_islands/JsxIsland.tsx";
import { NullIsland } from "./fixtures_islands/NullIsland.tsx";
import { PartialInIsland } from "./fixtures_islands/PartialInIsland.tsx";
import { PassThrough } from "./fixtures_islands/PassThrough.tsx";
import { SelfCounter } from "./fixtures_islands/SelfCounter.tsx";
import { Multiple1, Multiple2 } from "./fixtures_islands/Multiple.tsx";
import { Foo } from "./fixture_island_groups/routes/foo/(_islands)/Foo.tsx";
import { NodeProcess } from "./fixtures_islands/NodeProcess.tsx";
import { FreshAttrs } from "./fixtures_islands/FreshAttrs.tsx";
import { OptOutPartialLink } from "./fixtures_islands/OptOutPartialLink.tsx";

const browser = await launch({
  args: [
    "--window-size=1280,720",
    ...((Deno.env.get("CI") && Deno.build.os === "linux")
      ? ["--no-sandbox"]
      : []),
  ],
  headless: true,
});

export function getIsland(pathname: string) {
  return path.join(
    import.meta.dirname!,
    "fixtures_islands",
    pathname,
  );
}

export const charset = <meta charset="utf-8" />;

export const favicon = (
  <link
    href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII="
    rel="icon"
    type="image/x-icon"
  />
);

export function Doc(props: { children?: ComponentChildren; title?: string }) {