trickle-cli 0.1.209 → 0.1.210
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.
- package/dist/commands/test-gen.js +30 -6
- package/package.json +1 -1
- package/src/commands/test-gen.ts +32 -10
|
@@ -329,8 +329,15 @@ function generateRouteTestFile(routes, framework, baseUrl) {
|
|
|
329
329
|
}
|
|
330
330
|
lines.push(" });");
|
|
331
331
|
lines.push("");
|
|
332
|
+
// POST typically returns 201, others return 200
|
|
333
|
+
// Use expect(res.ok) which covers 200-299 range
|
|
332
334
|
lines.push(" expect(res.ok).toBe(true);");
|
|
333
|
-
|
|
335
|
+
if (hasBody) {
|
|
336
|
+
lines.push(" expect(res.status === 200 || res.status === 201).toBe(true);");
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
lines.push(` expect(res.status).toBe(200);`);
|
|
340
|
+
}
|
|
334
341
|
lines.push("");
|
|
335
342
|
lines.push(" const body = await res.json();");
|
|
336
343
|
if (route.sampleOutput && typeof route.sampleOutput === "object") {
|
|
@@ -698,15 +705,26 @@ function generateAssertions(obj, path, depth = 0) {
|
|
|
698
705
|
const assertions = [];
|
|
699
706
|
for (const [key, value] of Object.entries(obj)) {
|
|
700
707
|
const propPath = `${path}.${key}`;
|
|
708
|
+
// Skip truncated values from sanitizeSample — they have wrong types
|
|
709
|
+
if (value === "[truncated]") {
|
|
710
|
+
assertions.push(`expect(${propPath}).toBeDefined();`);
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
701
713
|
if (value === null) {
|
|
702
714
|
assertions.push(`expect(${propPath}).toBeNull();`);
|
|
703
715
|
}
|
|
704
716
|
else if (Array.isArray(value)) {
|
|
705
717
|
assertions.push(`expect(Array.isArray(${propPath})).toBe(true);`);
|
|
706
|
-
if (value.length > 0
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
718
|
+
if (value.length > 0) {
|
|
719
|
+
// Skip if first item is truncated
|
|
720
|
+
if (value[0] === "[truncated]") {
|
|
721
|
+
assertions.push(`expect(${propPath}.length).toBeGreaterThan(0);`);
|
|
722
|
+
}
|
|
723
|
+
else if (typeof value[0] === "object" && value[0] !== null) {
|
|
724
|
+
assertions.push(`expect(${propPath}.length).toBeGreaterThan(0);`);
|
|
725
|
+
const itemAssertions = generateAssertions(value[0], `${propPath}[0]`, depth + 1);
|
|
726
|
+
assertions.push(...itemAssertions);
|
|
727
|
+
}
|
|
710
728
|
}
|
|
711
729
|
}
|
|
712
730
|
else if (typeof value === "object") {
|
|
@@ -715,7 +733,13 @@ function generateAssertions(obj, path, depth = 0) {
|
|
|
715
733
|
assertions.push(...nestedAssertions);
|
|
716
734
|
}
|
|
717
735
|
else if (typeof value === "string") {
|
|
718
|
-
|
|
736
|
+
// Check if this looks like a truncated string from sanitizeSample
|
|
737
|
+
if (typeof value === "string" && value.endsWith("...")) {
|
|
738
|
+
assertions.push(`expect(typeof ${propPath}).toBe("string");`);
|
|
739
|
+
}
|
|
740
|
+
else {
|
|
741
|
+
assertions.push(`expect(typeof ${propPath}).toBe("string");`);
|
|
742
|
+
}
|
|
719
743
|
}
|
|
720
744
|
else if (typeof value === "number") {
|
|
721
745
|
assertions.push(`expect(typeof ${propPath}).toBe("number");`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trickle-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.210",
|
|
4
4
|
"description": "Zero-code runtime observability for JS/Python + AI agent debugging. Traces LangChain, CrewAI, OpenAI, Anthropic, Gemini. Eval, security, compliance, cost tracking. Free, local-first.",
|
|
5
5
|
"keywords": ["observability", "tracing", "llm", "openai", "anthropic", "langchain", "crewai", "agent", "mcp", "debugging", "typescript", "python", "security", "eval", "compliance"],
|
|
6
6
|
"bin": {
|
package/src/commands/test-gen.ts
CHANGED
|
@@ -371,8 +371,14 @@ function generateRouteTestFile(routes: MockRoute[], framework: string, baseUrl:
|
|
|
371
371
|
lines.push(" });");
|
|
372
372
|
lines.push("");
|
|
373
373
|
|
|
374
|
+
// POST typically returns 201, others return 200
|
|
375
|
+
// Use expect(res.ok) which covers 200-299 range
|
|
374
376
|
lines.push(" expect(res.ok).toBe(true);");
|
|
375
|
-
|
|
377
|
+
if (hasBody) {
|
|
378
|
+
lines.push(" expect(res.status === 200 || res.status === 201).toBe(true);");
|
|
379
|
+
} else {
|
|
380
|
+
lines.push(` expect(res.status).toBe(200);`);
|
|
381
|
+
}
|
|
376
382
|
lines.push("");
|
|
377
383
|
|
|
378
384
|
lines.push(" const body = await res.json();");
|
|
@@ -770,18 +776,29 @@ function generateAssertions(obj: Record<string, unknown>, path: string, depth =
|
|
|
770
776
|
for (const [key, value] of Object.entries(obj)) {
|
|
771
777
|
const propPath = `${path}.${key}`;
|
|
772
778
|
|
|
779
|
+
// Skip truncated values from sanitizeSample — they have wrong types
|
|
780
|
+
if (value === "[truncated]") {
|
|
781
|
+
assertions.push(`expect(${propPath}).toBeDefined();`);
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
|
|
773
785
|
if (value === null) {
|
|
774
786
|
assertions.push(`expect(${propPath}).toBeNull();`);
|
|
775
787
|
} else if (Array.isArray(value)) {
|
|
776
788
|
assertions.push(`expect(Array.isArray(${propPath})).toBe(true);`);
|
|
777
|
-
if (value.length > 0
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
789
|
+
if (value.length > 0) {
|
|
790
|
+
// Skip if first item is truncated
|
|
791
|
+
if (value[0] === "[truncated]") {
|
|
792
|
+
assertions.push(`expect(${propPath}.length).toBeGreaterThan(0);`);
|
|
793
|
+
} else if (typeof value[0] === "object" && value[0] !== null) {
|
|
794
|
+
assertions.push(`expect(${propPath}.length).toBeGreaterThan(0);`);
|
|
795
|
+
const itemAssertions = generateAssertions(
|
|
796
|
+
value[0] as Record<string, unknown>,
|
|
797
|
+
`${propPath}[0]`,
|
|
798
|
+
depth + 1,
|
|
799
|
+
);
|
|
800
|
+
assertions.push(...itemAssertions);
|
|
801
|
+
}
|
|
785
802
|
}
|
|
786
803
|
} else if (typeof value === "object") {
|
|
787
804
|
assertions.push(`expect(typeof ${propPath}).toBe("object");`);
|
|
@@ -792,7 +809,12 @@ function generateAssertions(obj: Record<string, unknown>, path: string, depth =
|
|
|
792
809
|
);
|
|
793
810
|
assertions.push(...nestedAssertions);
|
|
794
811
|
} else if (typeof value === "string") {
|
|
795
|
-
|
|
812
|
+
// Check if this looks like a truncated string from sanitizeSample
|
|
813
|
+
if (typeof value === "string" && (value as string).endsWith("...")) {
|
|
814
|
+
assertions.push(`expect(typeof ${propPath}).toBe("string");`);
|
|
815
|
+
} else {
|
|
816
|
+
assertions.push(`expect(typeof ${propPath}).toBe("string");`);
|
|
817
|
+
}
|
|
796
818
|
} else if (typeof value === "number") {
|
|
797
819
|
assertions.push(`expect(typeof ${propPath}).toBe("number");`);
|
|
798
820
|
} else if (typeof value === "boolean") {
|