@elsium-ai/testing 0.1.6 → 0.2.0

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/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # @elsium-ai/testing
2
+
3
+ Testing utilities, mock providers, fixtures, and eval framework for [ElsiumAI](https://github.com/elsium-ai/elsium-ai).
4
+
5
+ [![npm](https://img.shields.io/npm/v/@elsium-ai/testing.svg)](https://www.npmjs.com/package/@elsium-ai/testing)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/elsium-ai/elsium-ai/blob/main/LICENSE)
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @elsium-ai/testing --save-dev
12
+ ```
13
+
14
+ ## What's Inside
15
+
16
+ - **Mock Providers** — Zero-latency providers for unit testing
17
+ - **Evals** — LLM-as-judge evaluation framework
18
+ - **Output Pinning** — Lock expected outputs, catch regressions when models update
19
+ - **Determinism Assertions** — Run N times, verify all outputs match
20
+ - **Prompt Versioning** — Track and compare prompt versions
21
+ - **Request-Matched Fixtures** — Replay fixtures by content hash, not sequence order
22
+ - **Regression Suites** — Automated regression detection in CI
23
+
24
+ ## Usage
25
+
26
+ ```typescript
27
+ import { assertDeterministic, createMockProvider, pinOutput } from '@elsium-ai/testing'
28
+
29
+ // Determinism check
30
+ const result = await assertDeterministic(
31
+ (seed) => llm.complete({
32
+ messages: [{ role: 'user', content: 'Classify: spam' }],
33
+ temperature: 0,
34
+ seed,
35
+ }).then(r => r.message.content),
36
+ { runs: 5, seed: 42, tolerance: 0 },
37
+ )
38
+ // { deterministic: true, variance: 0, uniqueOutputs: 1 }
39
+
40
+ // Mock provider for tests
41
+ const mock = createMockProvider({
42
+ responses: [{ content: 'Mocked response' }],
43
+ })
44
+ ```
45
+
46
+ ## Part of ElsiumAI
47
+
48
+ This package is the testing layer of the [ElsiumAI](https://github.com/elsium-ai/elsium-ai) framework. See the [full documentation](https://github.com/elsium-ai/elsium-ai) for guides and examples.
49
+
50
+ ## License
51
+
52
+ [MIT](https://github.com/elsium-ai/elsium-ai/blob/main/LICENSE)
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- // @bun
2
1
  // ../core/src/errors.ts
3
2
  class ElsiumError extends Error {
4
3
  code;
@@ -89,7 +88,7 @@ class ElsiumError extends Error {
89
88
  }
90
89
  }
91
90
  // ../core/src/utils.ts
92
- import { randomBytes } from "crypto";
91
+ import { randomBytes } from "node:crypto";
93
92
  function cryptoHex(bytes) {
94
93
  return randomBytes(bytes).toString("hex");
95
94
  }
@@ -419,7 +418,7 @@ function mockProvider(options = {}) {
419
418
  };
420
419
  }
421
420
  // src/fixtures.ts
422
- import { createHash } from "crypto";
421
+ import { createHash } from "node:crypto";
423
422
  function hashMessages(messages) {
424
423
  const content = messages.map((m) => `${m.role}:${m.content}`).join("|");
425
424
  return createHash("sha256").update(content).digest("hex").slice(0, 16);
@@ -781,7 +780,7 @@ function formatEvalReport(result) {
781
780
  const lines = [];
782
781
  lines.push(`
783
782
  Eval Suite: ${result.name}`);
784
- lines.push(` ${"\u2500".repeat(50)}`);
783
+ lines.push(` ${"".repeat(50)}`);
785
784
  for (const r of result.results) {
786
785
  const icon = r.passed ? "PASS" : "FAIL";
787
786
  lines.push(` [${icon}] ${r.name} (${r.durationMs}ms)`);
@@ -793,14 +792,14 @@ function formatEvalReport(result) {
793
792
  }
794
793
  }
795
794
  }
796
- lines.push(` ${"\u2500".repeat(50)}`);
795
+ lines.push(` ${"".repeat(50)}`);
797
796
  lines.push(` Score: ${(result.score * 100).toFixed(1)}% | ${result.passed}/${result.total} passed | ${result.durationMs}ms`);
798
797
  lines.push("");
799
798
  return lines.join(`
800
799
  `);
801
800
  }
802
801
  // src/snapshot.ts
803
- import { createHash as createHash2 } from "crypto";
802
+ import { createHash as createHash2 } from "node:crypto";
804
803
  function createSnapshotStore(existing) {
805
804
  const snapshots = new Map;
806
805
  if (existing) {
@@ -975,8 +974,8 @@ function createPromptRegistry() {
975
974
  };
976
975
  }
977
976
  // src/regression.ts
978
- import { mkdirSync, readFileSync, writeFileSync } from "fs";
979
- import { dirname } from "path";
977
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
978
+ import { dirname } from "node:path";
980
979
  function makeEmptyResult(name) {
981
980
  return {
982
981
  name,
@@ -1131,7 +1130,7 @@ function createReplayPlayer(entriesOrJson) {
1131
1130
  };
1132
1131
  }
1133
1132
  // src/pinning.ts
1134
- import { createHash as createHash3 } from "crypto";
1133
+ import { createHash as createHash3 } from "node:crypto";
1135
1134
  function sha256(input) {
1136
1135
  return createHash3("sha256").update(input).digest("hex");
1137
1136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elsium-ai/testing",
3
- "version": "0.1.6",
3
+ "version": "0.2.0",
4
4
  "description": "Testing utilities, mock providers, fixtures, and eval framework for ElsiumAI",
5
5
  "license": "MIT",
6
6
  "author": "Eric Utrera <ebutrera9103@gmail.com>",
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "scripts": {
25
- "build": "bun build ./src/index.ts --outdir ./dist --target bun && bun x tsc -p tsconfig.build.json --emitDeclarationOnly",
25
+ "build": "bun build ./src/index.ts --outdir ./dist --target node && bun x tsc -p tsconfig.build.json --emitDeclarationOnly",
26
26
  "dev": "bun --watch src/index.ts"
27
27
  },
28
28
  "dependencies": {
@@ -32,7 +32,6 @@
32
32
  "@elsium-ai/tools": "workspace:*"
33
33
  },
34
34
  "devDependencies": {
35
- "bun-types": "^1.3.0",
36
35
  "typescript": "^5.7.0"
37
36
  }
38
37
  }