1import {
2 KvNamespace,
3 Text,
4} from "@alchemy.run/cloudflare-runtime/core/bindings";
5import * as Options from "@alchemy.run/cloudflare-test-tools/e2e/Options";
6import * as SvelteKit from "@alchemy.run/frontend-frameworks/sveltekit";
7
8const SECRET = "s3cret-from-binding";
9// FIXTURE_OVERRIDE exists as a real Text binding ("proxied-value") AND as a
10// framework-level `dev.env` literal ("literal-override"): in dev the literal
11// must win over the value served through the platform proxy (back-compat with
12// the phase-1 stub platform); live serves the binding value.
13const OVERRIDE_BINDING_VALUE = "proxied-value";
14const OVERRIDE_LITERAL_VALUE = "literal-override";
15
16export default Options.make({
17 // The typed factory form (harness contract form 3): map the harness
18 // options onto SvelteKit options, then pin the dev port so parallel fixture
19 // runs don't collide. `framework: "@alchemy.run/frontend-frameworks/sveltekit"` (the string
20 // form) works identically when no framework-specific options are needed.
21 // The deploy target defaults to `@alchemy.run/frontend-frameworks/sveltekit/cloudflare`.
22 framework: (options) => {
23 const base = SvelteKit.fromHarnessOptions(
24 options as SvelteKit.HarnessOptions,
25 );
26 return SvelteKit.layer({
27 ...base,
28 dev: {
29 ...base.dev,
30 port: 3103,
31 env: { FIXTURE_OVERRIDE: OVERRIDE_LITERAL_VALUE },
32 },
33 });
34 },
35 // Target-scoped config carriage: `target.cloudflare.worker` is what the
36 // framework package reads (compat date/flags, bindings, assets behavior);
37 // `target.cloudflare.preview` configures the miniflare preview server the
38 // harness's cloudflare target serves built output with.
39 target: {
40 cloudflare: {
41 worker: {
42 compatibilityDate: "2026-03-10",
43 compatibilityFlags: ["nodejs_compat"],
44 worker: {
45 name: "fixtures-sveltekit",
46 bindings: [
47 Text.local("FIXTURE_SECRET", SECRET),
48 Text.local("FIXTURE_OVERRIDE", OVERRIDE_BINDING_VALUE),
49 // a real (non-literal) resource binding: served in dev through
50 // cloudflare-runtime's platform proxy
51 KvNamespace.local({ binding: "FIXTURE_KV" }),
52 ],
53 assets: {
54 htmlHandling: "auto-trailing-slash",
55 notFoundHandling: "none",
56 runWorkerFirst: false,
57 },
58 },
59 },
60 preview: {
61 compatibilityDate: "2026-03-10",
62 compatibilityFlags: ["nodejs_compat"],
63 bindings: {
64 FIXTURE_SECRET: SECRET,
65 FIXTURE_OVERRIDE: OVERRIDE_BINDING_VALUE,
66 },
67 kvNamespaces: ["FIXTURE_KV"],
68 assets: {
69 binding: "ASSETS",
70 routerConfig: {
71 has_user_worker: true,
72 invoke_user_worker_ahead_of_assets: false,
73 },
74 assetConfig: {
75 html_handling: "auto-trailing-slash",
76 not_found_handling: "none",
77 },
78 },
79 },
80 },
81 },
82});