MCPcopy Create free account
hub / github.com/observablehq/framework / match

Method match

src/error.ts:81–92  ·  view source on GitHub ↗

Use in tests to check if a thrown error is the error you expected.

(
    error: unknown,
    {message, exitCode, print}: {message?: RegExp | string; exitCode?: number; print?: boolean} = {}
  )

Source from the content-addressed store, hash-verified

79
80 /** Use in tests to check if a thrown error is the error you expected. */
81 static match(
82 error: unknown,
83 {message, exitCode, print}: {message?: RegExp | string; exitCode?: number; print?: boolean} = {}
84 ): error is CliError {
85 if (!(error instanceof Error)) return false;
86 if (!(error instanceof CliError)) return false;
87 if (message !== undefined && typeof message === "string" && error.message !== message) return false;
88 if (message !== undefined && message instanceof RegExp && !message.test(error.message)) return false;
89 if (exitCode !== undefined && error.exitCode !== exitCode) return false;
90 if (print !== undefined && error.print !== print) return false;
91 return true;
92 }
93}

Callers 10

constructorMethod · 0.80
deploy-test.tsFile · 0.80
headersMatcherFunction · 0.80
assertLinesMethod · 0.80
getBuildFilePathsMethod · 0.80
promptDeployTargetFunction · 0.80
processTermFunction · 0.80
parseRangeFunction · 0.80
fromCellReferenceFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected