MCPcopy Create free account
hub / github.com/CopilotKit/OpenTag / runExpectations

Function runExpectations

e2e/run.ts:58–87  ·  view source on GitHub ↗
(
  exp: NonNullable<E2ECase["expectations"]>,
  finalText: string | undefined,
  errors: string[],
  prefix = "",
)

Source from the content-addressed store, hash-verified

56}
57
58function runExpectations(
59 exp: NonNullable<E2ECase["expectations"]>,
60 finalText: string | undefined,
61 errors: string[],
62 prefix = "",
63): void {
64 const tag = prefix ? `${prefix}: ` : "";
65 if (exp.finalContains) {
66 for (const needle of exp.finalContains) {
67 if (!(finalText ?? "").toLowerCase().includes(needle.toLowerCase())) {
68 errors.push(`${tag}missing: ${JSON.stringify(needle)}`);
69 }
70 }
71 }
72 if (exp.finalNotContains) {
73 for (const needle of exp.finalNotContains) {
74 if ((finalText ?? "").toLowerCase().includes(needle.toLowerCase())) {
75 errors.push(`${tag}contained forbidden: ${JSON.stringify(needle)}`);
76 }
77 }
78 }
79 if (exp.balancedBrackets && finalText && !isBalanced(finalText)) {
80 errors.push(`${tag}text has unbalanced brackets`);
81 }
82 if (exp.minLength && (finalText?.length ?? 0) < exp.minLength) {
83 errors.push(
84 `${tag}too short (${finalText?.length ?? 0} < ${exp.minLength})`,
85 );
86 }
87}
88
89async function runCase(spec: E2ECase): Promise<CaseResult> {
90 const errors: string[] = [];

Callers 1

runCaseFunction · 0.70

Calls 1

isBalancedFunction · 0.70

Tested by

no test coverage detected