sedum-cli 0.1.0-alpha.3 → 0.1.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ var ProjectConfigError = class extends Error {
15
15
  };
16
16
  var DEFAULTS = {
17
17
  testDirectory: "tests",
18
- include: ["**/*.test.yaml"],
18
+ include: ["**/*.test.ts", "**/*.test.yaml"],
19
19
  exclude: [],
20
20
  browser: "chrome",
21
21
  viewport: { width: 1280, height: 900 },
@@ -25,7 +25,12 @@ var DEFAULTS = {
25
25
  contradictionCutoff: 0.5
26
26
  },
27
27
  outputDir: ".sedum/runs",
28
- reporterDir: ".sedum/reports"
28
+ reporterDir: ".sedum/reports",
29
+ vision: {
30
+ enabled: false,
31
+ model: "google/gemini-3.8-flash",
32
+ timeoutMs: 1e4
33
+ }
29
34
  };
30
35
  var DEFAULT_PROVIDER_BASE_URL = "https://api.typesafe.ai";
31
36
  var DEFAULT_PROVIDER_MODEL = "jev-latest";
@@ -40,12 +45,14 @@ var allowed = {
40
45
  "baseUrl",
41
46
  "environment",
42
47
  "variables",
43
- "environments"
48
+ "environments",
49
+ "vision"
44
50
  ]),
45
51
  tests: /* @__PURE__ */ new Set(["directory", "include", "exclude"]),
46
52
  viewport: /* @__PURE__ */ new Set(["width", "height"]),
47
53
  thresholds: /* @__PURE__ */ new Set(["verify", "lowConfidenceBand", "contradiction"]),
48
- environment: /* @__PURE__ */ new Set(["baseUrl", "variables"])
54
+ environment: /* @__PURE__ */ new Set(["baseUrl", "variables"]),
55
+ vision: /* @__PURE__ */ new Set(["enabled", "model", "timeoutMs"])
49
56
  };
50
57
  function source(file, counter, node) {
51
58
  const position = counter.linePos(node?.range?.[0] ?? 0);
@@ -73,9 +80,30 @@ function mapUnknownKeys(value, names, prefix, file, counter, diagnostics) {
73
80
  prefix ? `${prefix}.${key}` : key,
74
81
  "unknown_config_key",
75
82
  `Unknown configuration key \`${prefix ? `${prefix}.` : ""}${key}\`.`,
76
- "Remove the key or use one documented by `sedum run --help`."
83
+ keyFix(key, names)
84
+ );
85
+ }
86
+ }
87
+ function distance(left, right) {
88
+ const row = Array.from({ length: right.length + 1 }, (_, i) => i);
89
+ for (let i = 1; i <= left.length; i++) {
90
+ let previous = row[0];
91
+ row[0] = i;
92
+ for (let j = 1; j <= right.length; j++) {
93
+ const saved = row[j];
94
+ row[j] = Math.min(
95
+ row[j] + 1,
96
+ row[j - 1] + 1,
97
+ previous + (left[i - 1] === right[j - 1] ? 0 : 1)
77
98
  );
99
+ previous = saved;
100
+ }
78
101
  }
102
+ return row[right.length];
103
+ }
104
+ function keyFix(key, names) {
105
+ const [closest] = [...names].map((known) => ({ known, score: distance(key, known) })).sort((a, b) => a.score - b.score || a.known.localeCompare(b.known));
106
+ return closest && closest.score <= 2 ? `Did you mean \`${closest.known}\`?` : "Remove the key or use one documented in docs/configuration.md.";
79
107
  }
80
108
  function object(value) {
81
109
  return value !== null && typeof value === "object" && !Array.isArray(value);
@@ -97,7 +125,7 @@ function scalarVariables(value, key, diagnostics, file, counter, node) {
97
125
  }
98
126
  const result = {};
99
127
  for (const [name, item] of Object.entries(value)) {
100
- if (name === "TYPESAFE_API_KEY") {
128
+ if (name === "TYPESAFE_API_KEY" || name === "OPEN_ROUTER_API_KEY") {
101
129
  diagnostic(
102
130
  diagnostics,
103
131
  file,
@@ -203,7 +231,7 @@ function stringList(value, fallback, key, diagnostics, file, counter, node) {
203
231
  key,
204
232
  "invalid_config_globs",
205
233
  `Configuration key \`${key}\` must be a list of nonempty glob strings.`,
206
- `Write \`${key}: ["**/*.test.yaml"]\`.`
234
+ `Write \`${key}: ["**/*.test.ts", "**/*.test.yaml"]\`.`
207
235
  );
208
236
  return [...fallback];
209
237
  }
@@ -275,6 +303,7 @@ function freeze(config) {
275
303
  Object.freeze(config.exclude);
276
304
  Object.freeze(config.viewport);
277
305
  Object.freeze(config.thresholds);
306
+ Object.freeze(config.vision);
278
307
  Object.freeze(config.variables);
279
308
  return Object.freeze(config);
280
309
  }
@@ -373,7 +402,8 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
373
402
  const maps = [
374
403
  ["tests", allowed.tests],
375
404
  ["viewport", allowed.viewport],
376
- ["thresholds", allowed.thresholds]
405
+ ["thresholds", allowed.thresholds],
406
+ ["vision", allowed.vision]
377
407
  ];
378
408
  for (const [key, names] of maps)
379
409
  mapUnknownKeys(
@@ -412,7 +442,8 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
412
442
  for (const [key, value] of [
413
443
  ["viewport", raw.viewport],
414
444
  ["thresholds", raw.thresholds],
415
- ["environments", raw.environments]
445
+ ["environments", raw.environments],
446
+ ["vision", raw.vision]
416
447
  ])
417
448
  if (value !== void 0 && !object(value))
418
449
  diagnostic(
@@ -428,6 +459,7 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
428
459
  const viewport = object(raw.viewport) ? raw.viewport : {};
429
460
  const thresholds = object(raw.thresholds) ? raw.thresholds : {};
430
461
  const environments = object(raw.environments) ? raw.environments : {};
462
+ const vision = object(raw.vision) ? raw.vision : {};
431
463
  for (const [name, value] of Object.entries(environments)) {
432
464
  if (!object(value)) {
433
465
  diagnostic(
@@ -599,7 +631,7 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
599
631
  "tests.include",
600
632
  "empty_config_globs",
601
633
  "Configuration key `tests.include` must select at least one pattern.",
602
- "Add `**/*.test.yaml` or another test glob."
634
+ "Add `**/*.test.ts` or another test glob."
603
635
  );
604
636
  const variables = {
605
637
  ...rootVariables,
@@ -633,6 +665,46 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
633
665
  }
634
666
  const providerModel = customProvider.model ?? DEFAULT_PROVIDER_MODEL;
635
667
  const apiKey = providerValue("TYPESAFE_API_KEY");
668
+ const visionApiKey = providerValue("OPEN_ROUTER_API_KEY");
669
+ variables.OPEN_ROUTER_API_KEY = void 0;
670
+ const visionEnabledValue = overrides.vision?.enabled ?? vision.enabled;
671
+ const visionEnabled = visionEnabledValue ?? DEFAULTS.vision.enabled;
672
+ if (typeof visionEnabled !== "boolean")
673
+ diagnostic(
674
+ diagnostics,
675
+ file,
676
+ counter,
677
+ node("vision.enabled"),
678
+ "vision.enabled",
679
+ "invalid_config_type",
680
+ "Configuration key `vision.enabled` must be a boolean.",
681
+ "Use `vision.enabled: true` or `vision.enabled: false`."
682
+ );
683
+ const visionModelValue = overrides.vision?.model ?? vision.model;
684
+ const visionModel = visionModelValue ?? DEFAULTS.vision.model;
685
+ if (typeof visionModel !== "string" || !visionModel.trim())
686
+ diagnostic(
687
+ diagnostics,
688
+ file,
689
+ counter,
690
+ node("vision.model"),
691
+ "vision.model",
692
+ "invalid_config_type",
693
+ "Configuration key `vision.model` must be nonempty text.",
694
+ `Use a model such as \`${DEFAULTS.vision.model}\`.`
695
+ );
696
+ const visionTimeoutValue = vision.timeoutMs ?? DEFAULTS.vision.timeoutMs;
697
+ if (!Number.isSafeInteger(visionTimeoutValue) || visionTimeoutValue < 1)
698
+ diagnostic(
699
+ diagnostics,
700
+ file,
701
+ counter,
702
+ node("vision.timeoutMs"),
703
+ "vision.timeoutMs",
704
+ "invalid_config_type",
705
+ "Configuration key `vision.timeoutMs` must be a positive integer.",
706
+ "Use a timeout such as `10000`."
707
+ );
636
708
  const testDirectory = relativePath(
637
709
  found.root,
638
710
  tests.directory,
@@ -698,7 +770,13 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
698
770
  variables,
699
771
  apiKey,
700
772
  providerBaseUrl,
701
- providerModel
773
+ providerModel,
774
+ vision: {
775
+ enabled: visionEnabled === true,
776
+ model: typeof visionModel === "string" && visionModel.trim() ? visionModel : DEFAULTS.vision.model,
777
+ timeoutMs: Number.isSafeInteger(visionTimeoutValue) && visionTimeoutValue > 0 ? visionTimeoutValue : DEFAULTS.vision.timeoutMs
778
+ },
779
+ visionApiKey
702
780
  });
703
781
  }
704
782
  async function discoverConfiguredTests(config) {
@@ -717,7 +795,7 @@ async function discoverConfiguredTests(config) {
717
795
  if (entry.isDirectory()) await visit2(absolute);
718
796
  else if (entry.isFile()) {
719
797
  const relative = path.relative(config.testDirectory, absolute).split(path.sep).join("/");
720
- if (relative.endsWith(".test.yaml") && config.include.some((pattern) => minimatch(relative, pattern)) && !config.exclude.some((pattern) => minimatch(relative, pattern)))
798
+ if ((relative.endsWith(".test.ts") || relative.endsWith(".test.yaml")) && config.include.some((pattern) => minimatch(relative, pattern)) && !config.exclude.some((pattern) => minimatch(relative, pattern)))
721
799
  files.push(absolute);
722
800
  }
723
801
  }
@@ -2,12 +2,15 @@ import {
2
2
  DEFAULT_PROVIDER_BASE_URL,
3
3
  DEFAULT_PROVIDER_MODEL,
4
4
  loadProjectConfig
5
- } from "./chunk-YXSAX7E3.js";
5
+ } from "./chunk-GYFQYSYT.js";
6
6
 
7
7
  // src/doctor-command.ts
8
8
  import { lstat, mkdir, mkdtemp, rm, rmdir, writeFile } from "fs/promises";
9
9
  import path from "path";
10
- import { findBrowserExecutable } from "@sedum-dev/core";
10
+ import {
11
+ findBrowserExecutable,
12
+ probeOpenRouterKey
13
+ } from "@sedum-dev/core";
11
14
  import {
12
15
  probeTypeSafeApiKey
13
16
  } from "@sedum-dev/provider-typesafe";
@@ -79,7 +82,7 @@ async function checkOutputWritable(config) {
79
82
  }
80
83
  }
81
84
  }
82
- async function executeDoctorCommand(cwd, probes = {}) {
85
+ async function executeDoctorCommand(cwd, probes = {}, options = {}) {
83
86
  const checks = [];
84
87
  const version = probes.nodeVersion ?? process.versions.node;
85
88
  checks.push(
@@ -207,6 +210,42 @@ async function executeDoctorCommand(cwd, probes = {}) {
207
210
  )
208
211
  );
209
212
  }
213
+ if (config && (options.vision || config.vision.enabled)) {
214
+ const visionKey = config.visionApiKey?.trim();
215
+ checks.push(
216
+ visionKey ? pass(
217
+ "vision_key",
218
+ "OpenRouter API key for vision fallback is present."
219
+ ) : fail(
220
+ "vision_key",
221
+ "Vision fallback is enabled but OPEN_ROUTER_API_KEY is missing.",
222
+ "Set OPEN_ROUTER_API_KEY in the environment or the project-root .env."
223
+ )
224
+ );
225
+ if (visionKey) {
226
+ const result = await (probes.visionAuth ?? probeOpenRouterKey)(
227
+ visionKey
228
+ ).catch(() => "unreachable");
229
+ checks.push(
230
+ result === "accepted" ? pass("vision_auth", "OpenRouter accepted the vision key.") : result === "rejected" ? fail(
231
+ "vision_auth",
232
+ "OpenRouter rejected OPEN_ROUTER_API_KEY.",
233
+ "Replace OPEN_ROUTER_API_KEY with a valid OpenRouter key and rerun doctor."
234
+ ) : fail(
235
+ "vision_auth",
236
+ "OpenRouter could not be reached to check the vision key.",
237
+ "Check access to https://openrouter.ai and retry."
238
+ )
239
+ );
240
+ } else
241
+ checks.push(
242
+ fail(
243
+ "vision_auth",
244
+ "The vision key could not be checked without a key.",
245
+ "Set OPEN_ROUTER_API_KEY, then rerun doctor."
246
+ )
247
+ );
248
+ }
210
249
  if (config) {
211
250
  try {
212
251
  await (probes.output ?? checkOutputWritable)(config);
package/dist/cli.js CHANGED
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- runCli
4
- } from "./chunk-AZJ7JJ6P.js";
5
- import "./chunk-BI32AXS7.js";
6
- import "./chunk-YXSAX7E3.js";
3
+ runCli,
4
+ sedumCommand
5
+ } from "./chunk-2BOXJT7M.js";
6
+ import "./chunk-BEY4UNIW.js";
7
+ import "./chunk-GYFQYSYT.js";
7
8
 
8
9
  // src/cli.ts
9
10
  import { createRequire } from "module";
11
+ import { fileURLToPath } from "url";
10
12
 
11
13
  // src/interrupts.ts
12
14
  function createInterruptState() {
@@ -35,10 +37,26 @@ function startDeadlineWatchdog(delayMs = 1e4, exit = (code) => process.exit(code
35
37
  }
36
38
 
37
39
  // src/cli.ts
40
+ import { describeRejection, RejectionRouter } from "@sedum-dev/core";
38
41
  var require2 = createRequire(import.meta.url);
39
42
  var pkg = require2("../package.json");
40
43
  var interrupts = createInterruptState();
41
44
  var deadlineWatchdog;
45
+ var strayRejection = false;
46
+ var reportStray = (message) => {
47
+ strayRejection = true;
48
+ process.stderr.write(
49
+ `${message}
50
+ Fix: Add \`await\` before the page, expect, API, and ai calls in your tests.
51
+ `
52
+ );
53
+ };
54
+ process.on("unhandledRejection", (reason) => {
55
+ if (RejectionRouter.routing) return;
56
+ reportStray(
57
+ `A promise nobody awaited rejected outside any running test: ${describeRejection(reason)}`
58
+ );
59
+ });
42
60
  var onSigint = () => interrupts.request("SIGINT");
43
61
  var onSigterm = () => interrupts.request("SIGTERM");
44
62
  process.on("SIGINT", onSigint);
@@ -46,6 +64,7 @@ process.on("SIGTERM", onSigterm);
46
64
  var output = await runCli(process.argv.slice(2), pkg.version, {
47
65
  signal: interrupts.signal,
48
66
  onRunCommitted: interrupts.commit,
67
+ onStrayRejection: reportStray,
49
68
  onRunDeadline: () => {
50
69
  deadlineWatchdog = startDeadlineWatchdog();
51
70
  },
@@ -55,6 +74,7 @@ var output = await runCli(process.argv.slice(2), pkg.version, {
55
74
  color: process.stdout.isTTY === true && !("NO_COLOR" in process.env),
56
75
  ...process.stdout.columns ? { columns: process.stdout.columns } : {}
57
76
  },
77
+ command: sedumCommand(process.env, fileURLToPath(import.meta.url)),
58
78
  stdout: (value) => process.stdout.write(value),
59
79
  stderr: (value) => process.stderr.write(value)
60
80
  });
@@ -63,4 +83,9 @@ process.off("SIGINT", onSigint);
63
83
  process.off("SIGTERM", onSigterm);
64
84
  if (output.stdout) process.stdout.write(output.stdout);
65
85
  if (output.stderr) process.stderr.write(output.stderr);
66
- process.exitCode = interrupts.exitCode(output.exitCode);
86
+ var exitCode = interrupts.exitCode(output.exitCode);
87
+ process.exitCode = strayRejection ? Math.max(exitCode, 3) : exitCode;
88
+ process.on("beforeExit", () => {
89
+ if (strayRejection)
90
+ process.exitCode = Math.max(Number(process.exitCode ?? 0), 3);
91
+ });
@@ -5,8 +5,8 @@ import {
5
5
  keyPresent,
6
6
  renderDoctorText,
7
7
  supportedNode
8
- } from "./chunk-CZDCGWWD.js";
9
- import "./chunk-YXSAX7E3.js";
8
+ } from "./chunk-NMAMFLDA.js";
9
+ import "./chunk-GYFQYSYT.js";
10
10
  export {
11
11
  browserAvailable,
12
12
  checkOutputWritable,
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { RunResult, BrowserKind, VerifyPolicy, ClassificationProvider, BrowserInstallResult } from '@sedum-dev/core';
1
+ import { RunResult, BrowserKind, VerifyPolicy, VisionKeyProbe, ClassificationProvider, BrowserInstallResult } from '@sedum-dev/core';
2
2
  import { TypeSafeAdapter, AuthProbeResult } from '@sedum-dev/provider-typesafe';
3
+ export { Ai, AiValue, AiValues, BrowserContext, Locator, Page, Parser, SecretValue, TestBody, TestContext, TestInfo, TestOptions, expect, secret, test } from '@sedum-dev/core/script';
3
4
 
4
5
  interface OutputCapabilities {
5
6
  readonly stdoutIsTTY: boolean;
@@ -42,6 +43,10 @@ interface ProjectConfigOverrides {
42
43
  readonly outputDir?: string;
43
44
  readonly reporterDir?: string;
44
45
  readonly baseUrl?: string;
46
+ readonly vision?: {
47
+ readonly enabled?: boolean;
48
+ readonly model?: string;
49
+ };
45
50
  }
46
51
  interface ResolvedProjectConfig {
47
52
  readonly projectRoot: string;
@@ -63,6 +68,12 @@ interface ResolvedProjectConfig {
63
68
  readonly apiKey: string | undefined;
64
69
  readonly providerBaseUrl: string;
65
70
  readonly providerModel: string;
71
+ readonly vision: {
72
+ readonly enabled: boolean;
73
+ readonly model: string;
74
+ readonly timeoutMs: number;
75
+ };
76
+ readonly visionApiKey: string | undefined;
66
77
  }
67
78
  interface ProjectConfigLoadOptions {
68
79
  /**
@@ -85,6 +96,8 @@ interface RunFilters {
85
96
  readonly exclude?: readonly string[];
86
97
  readonly labels?: readonly string[];
87
98
  readonly names?: readonly string[];
99
+ /** Exact test ids; rerun commands use these to select one test. */
100
+ readonly ids?: readonly string[];
88
101
  }
89
102
 
90
103
  type ParallelRequest = number | "auto";
@@ -96,11 +109,18 @@ interface ShardSpec {
96
109
  }
97
110
 
98
111
  interface RunCommandOptions {
112
+ /**
113
+ * Receives a stray rejection from test code that arrived after the run was
114
+ * reported; the `sedum` binary prints it and fails the exit code.
115
+ */
116
+ readonly onStrayRejection?: (message: string) => void;
99
117
  readonly file?: string;
100
118
  readonly paths?: readonly string[];
101
119
  readonly filters?: RunFilters;
102
120
  readonly environment?: string;
103
121
  readonly browser?: string;
122
+ readonly vision?: boolean;
123
+ readonly visionModel?: string;
104
124
  readonly urlOverride?: string;
105
125
  readonly outputDir?: string;
106
126
  readonly reporterDir?: string;
@@ -119,12 +139,16 @@ interface RunCommandOptions {
119
139
  readonly providerConcurrency?: number;
120
140
  /** Injected for tests; defaults to `os.availableParallelism()`. */
121
141
  readonly availableParallelism?: number;
142
+ /** Injected for tests; defaults to OpenRouter's unbilled key endpoint. */
143
+ readonly probeVisionKey?: (apiKey: string) => Promise<VisionKeyProbe>;
122
144
  readonly replay: boolean;
123
145
  readonly evidence: boolean;
124
146
  readonly sensitiveOrigins: readonly string[];
125
147
  readonly locatorCacheDisabled?: boolean;
126
148
  readonly locatorCacheCi?: boolean;
127
149
  readonly signal?: AbortSignal;
150
+ /** How to invoke sedum in report rerun hints, e.g. `npx sedum`. */
151
+ readonly command?: string;
128
152
  readonly onSnapshot?: (snapshot: RunResult, artifacts: RunArtifactPaths) => void;
129
153
  readonly onCommitted?: () => void;
130
154
  readonly onDeadline?: () => void;
@@ -149,6 +173,7 @@ interface DoctorProbes {
149
173
  readonly model: string;
150
174
  }) => Promise<AuthProbeResult>;
151
175
  readonly output?: (config: ResolvedProjectConfig) => Promise<void>;
176
+ readonly visionAuth?: (apiKey: string) => Promise<VisionKeyProbe>;
152
177
  }
153
178
 
154
179
  type ClassificationProviderFactory = (options: {
@@ -169,6 +194,8 @@ interface CliRuntime {
169
194
  readonly signal?: AbortSignal;
170
195
  readonly onRunCommitted?: () => void;
171
196
  readonly onRunDeadline?: () => void;
197
+ /** A stray rejection from test code after the run was reported. */
198
+ readonly onStrayRejection?: (message: string) => void;
172
199
  readonly executeRun?: (options: RunCommandOptions) => Promise<RunCommandExecution>;
173
200
  readonly installChromium?: (withDependencies: boolean) => BrowserInstallResult;
174
201
  /** Project root for `validate` and `list`; defaults to the process cwd. */
@@ -177,6 +204,8 @@ interface CliRuntime {
177
204
  readonly createClassificationProvider?: ClassificationProviderFactory;
178
205
  readonly createRelevanceProvider?: RelevanceProviderFactory;
179
206
  readonly doctorProbes?: DoctorProbes;
207
+ /** How the user invokes sedum, for hints; the entry point detects it. */
208
+ readonly command?: "sedum" | "npx sedum";
180
209
  readonly confirmInit?: (question: string) => Promise<boolean>;
181
210
  }
182
211
  /** Parse and execute explicit argv without reading or exiting the process. */
package/dist/index.js CHANGED
@@ -2,18 +2,24 @@ import {
2
2
  renderRunSummary,
3
3
  runCli,
4
4
  runExitCode
5
- } from "./chunk-AZJ7JJ6P.js";
6
- import "./chunk-BI32AXS7.js";
5
+ } from "./chunk-2BOXJT7M.js";
6
+ import "./chunk-BEY4UNIW.js";
7
7
  import {
8
8
  ProjectConfigError,
9
9
  discoverConfiguredTests,
10
10
  loadProjectConfig
11
- } from "./chunk-YXSAX7E3.js";
11
+ } from "./chunk-GYFQYSYT.js";
12
+
13
+ // src/index.ts
14
+ import { test, expect, secret } from "@sedum-dev/core/script";
12
15
  export {
13
16
  ProjectConfigError,
14
17
  discoverConfiguredTests,
18
+ expect,
15
19
  loadProjectConfig,
16
20
  renderRunSummary,
17
21
  runCli,
18
- runExitCode
22
+ runExitCode,
23
+ secret,
24
+ test
19
25
  };
@@ -2,11 +2,11 @@ import {
2
2
  browserAvailable,
3
3
  keyPresent,
4
4
  supportedNode
5
- } from "./chunk-CZDCGWWD.js";
5
+ } from "./chunk-NMAMFLDA.js";
6
6
  import {
7
7
  ProjectConfigError,
8
8
  loadProjectConfig
9
- } from "./chunk-YXSAX7E3.js";
9
+ } from "./chunk-GYFQYSYT.js";
10
10
 
11
11
  // src/init-command.ts
12
12
  import { constants } from "fs";
@@ -19,16 +19,20 @@ browser: chromium
19
19
  outputDir: .sedum/runs
20
20
  reporterDir: .sedum/reports
21
21
  `;
22
- var EXAMPLE = `description: Sign in to the SauceDemo sample store
23
- url: https://www.saucedemo.com/
24
- data:
25
- user: standard_user
26
- password: $SAUCE_PASSWORD
27
- steps:
28
- - type {{user}} in the username field
29
- - type {{password}} in the password field
30
- - click the login button
31
- - verify a list of products with prices is shown
22
+ var EXAMPLE = `import { test, secret } from "sedum-cli";
23
+
24
+ test(
25
+ "a customer signs in to the SauceDemo sample store",
26
+ { url: "https://www.saucedemo.com/" },
27
+ async ({ ai, env }) => {
28
+ await ai("type {{user}} in the username field", { user: "standard_user" });
29
+ await ai("type {{password}} in the password field", {
30
+ password: secret(env.SAUCE_PASSWORD ?? ""),
31
+ });
32
+ await ai("click the login button");
33
+ await ai("verify a list of products with prices is shown");
34
+ },
35
+ );
32
36
  `;
33
37
  var ENV_EXAMPLE = `# Get a TypeSafe key and put it in .env, or set it in your shell.
34
38
  # For a compatible provider, also set TYPESAFE_BASE_URL and optionally TYPESAFE_DEFAULT_MODEL.
@@ -153,12 +157,12 @@ async function executeInitCommand(options) {
153
157
  await regularDirectory(path.join(root, "tests"));
154
158
  for (const [name, contents] of [
155
159
  ["sedum.config.yaml", CONFIG],
156
- ["tests/example.test.yaml", EXAMPLE],
160
+ ["tests/example.test.ts", EXAMPLE],
157
161
  [".env.example", ENV_EXAMPLE]
158
162
  ]) {
159
163
  const result = await createOrKeep(path.join(root, name), contents);
160
164
  if (name === ".env.example" && result === "kept") keptEnvExample = true;
161
- if (name === "tests/example.test.yaml" && result === "created")
165
+ if (name === "tests/example.test.ts" && result === "created")
162
166
  createdExample = true;
163
167
  say(`${result} ${name}
164
168
  `);
@@ -166,7 +170,7 @@ async function executeInitCommand(options) {
166
170
  say(await updateIgnore(root, options));
167
171
  say("\nSedum runs plain-language tests in a browser.\n");
168
172
  if (createdExample) {
169
- const title = "\u2500\u2500 tests/example.test.yaml ";
173
+ const title = "\u2500\u2500 tests/example.test.ts ";
170
174
  const divider = "\u2500".repeat(54);
171
175
  say(`
172
176
  ${title}${divider.slice(title.length)}
@@ -219,7 +223,7 @@ ${++step}. ${title}
219
223
  ]);
220
224
  }
221
225
  next("Run the example", [
222
- "sedum run tests/example.test.yaml --headed",
226
+ "sedum run tests/example.test.ts --headed",
223
227
  "This calls the TypeSafe API and may incur a charge."
224
228
  ]);
225
229
  return { stdout: output.join(""), stderr: "", exitCode: 0 };