@lssm/lib.testing 0.4.1 → 1.41.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/lib.testing",
3
- "version": "0.4.1",
3
+ "version": "1.41.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -22,19 +22,23 @@
22
22
  "test": "bun run"
23
23
  },
24
24
  "dependencies": {
25
- "@lssm/lib.contracts": "^1.11.1"
25
+ "@lssm/lib.contracts": "workspace:*"
26
26
  },
27
27
  "devDependencies": {
28
- "@lssm/tool.tsdown": "0.12.1",
29
- "@lssm/tool.typescript": "0.11.1",
30
- "tsdown": "^0.16.6",
28
+ "@lssm/tool.tsdown": "workspace:*",
29
+ "@lssm/tool.typescript": "workspace:*",
30
+ "tsdown": "^0.17.4",
31
31
  "typescript": "^5.9.3"
32
32
  },
33
33
  "exports": {
34
- ".": "./dist/index.js",
34
+ ".": "./src/index.ts",
35
35
  "./*": "./*"
36
36
  },
37
37
  "publishConfig": {
38
- "access": "public"
38
+ "access": "public",
39
+ "exports": {
40
+ ".": "./dist/index.js",
41
+ "./*": "./*"
42
+ }
39
43
  }
40
44
  }
@@ -1,12 +0,0 @@
1
- import { GoldenTestCase } from "../types.js";
2
-
3
- //#region src/adapters/jest-adapter.d.ts
4
- interface JestAdapterOptions {
5
- suiteName: string;
6
- cases: GoldenTestCase[];
7
- runnerImport: string;
8
- runnerFunction: string;
9
- }
10
- declare function generateJestSuite(options: JestAdapterOptions): string;
11
- //#endregion
12
- export { JestAdapterOptions, generateJestSuite };
@@ -1,12 +0,0 @@
1
- import { GoldenTestCase } from "../types.js";
2
-
3
- //#region src/adapters/vitest-adapter.d.ts
4
- interface VitestAdapterOptions {
5
- suiteName: string;
6
- cases: GoldenTestCase[];
7
- runnerImport: string;
8
- runnerFunction: string;
9
- }
10
- declare function generateVitestSuite(options: VitestAdapterOptions): string;
11
- //#endregion
12
- export { VitestAdapterOptions, generateVitestSuite };
@@ -1,11 +0,0 @@
1
- import { GoldenTestCase } from "../types.js";
2
-
3
- //#region src/generator/assertion-builder.d.ts
4
- interface AssertionContext {
5
- runnerCall: string;
6
- caseRef: string;
7
- }
8
- declare function buildAssertions(testCase: GoldenTestCase, ctx: AssertionContext): string;
9
- declare function serialize(value: unknown): string;
10
- //#endregion
11
- export { AssertionContext, buildAssertions, serialize };
@@ -1,26 +0,0 @@
1
- import { GoldenTestCase, TrafficSnapshot } from "../types.js";
2
-
3
- //#region src/generator/golden-test-generator.d.ts
4
- interface GoldenTestGeneratorOptions {
5
- suiteName: string;
6
- runnerImport: string;
7
- runnerFunction: string;
8
- framework?: 'vitest' | 'jest';
9
- serializeMetadata?: (snapshot: TrafficSnapshot) => Record<string, unknown>;
10
- }
11
- declare class GoldenTestGenerator {
12
- private readonly serializeMetadata;
13
- constructor(serializeMetadata?: GoldenTestGeneratorOptions['serializeMetadata']);
14
- createCases(snapshots: TrafficSnapshot[]): GoldenTestCase[];
15
- generate(snapshots: TrafficSnapshot[], options: GoldenTestGeneratorOptions): string;
16
- }
17
- type GoldenTestRunner = (input: unknown, metadata?: Record<string, unknown>) => Promise<unknown>;
18
- interface GoldenTestRunResult {
19
- caseId: string;
20
- passed: boolean;
21
- durationMs: number;
22
- error?: unknown;
23
- }
24
- declare function runGoldenTests(cases: GoldenTestCase[], runner: GoldenTestRunner): Promise<GoldenTestRunResult[]>;
25
- //#endregion
26
- export { GoldenTestGenerator, GoldenTestGeneratorOptions, GoldenTestRunResult, GoldenTestRunner, runGoldenTests };
package/dist/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { GoldenTestCase, RuntimeContract, TrafficSnapshot } from "./types.js";
2
- import { InMemoryTrafficStore, RecordOperationInput, TrafficRecorder, TrafficRecorderOptions, TrafficStore } from "./recorder/traffic-recorder.js";
3
- import { GoldenTestGenerator, GoldenTestGeneratorOptions, GoldenTestRunResult, GoldenTestRunner, runGoldenTests } from "./generator/golden-test-generator.js";
4
- import { AssertionContext, buildAssertions, serialize } from "./generator/assertion-builder.js";
5
- import { VitestAdapterOptions, generateVitestSuite } from "./adapters/vitest-adapter.js";
6
- import { JestAdapterOptions, generateJestSuite } from "./adapters/jest-adapter.js";
7
- export { AssertionContext, GoldenTestCase, GoldenTestGenerator, GoldenTestGeneratorOptions, GoldenTestRunResult, GoldenTestRunner, InMemoryTrafficStore, JestAdapterOptions, RecordOperationInput, RuntimeContract, TrafficRecorder, TrafficRecorderOptions, TrafficSnapshot, TrafficStore, VitestAdapterOptions, buildAssertions, generateJestSuite, generateVitestSuite, runGoldenTests, serialize };
@@ -1,39 +0,0 @@
1
- import { TrafficSnapshot } from "../types.js";
2
-
3
- //#region src/recorder/traffic-recorder.d.ts
4
- interface TrafficStore {
5
- save(snapshot: TrafficSnapshot): Promise<void>;
6
- list(operation?: TrafficSnapshot['operation']['name']): Promise<TrafficSnapshot[]>;
7
- }
8
- declare class InMemoryTrafficStore implements TrafficStore {
9
- private readonly items;
10
- save(snapshot: TrafficSnapshot): Promise<void>;
11
- list(operation?: string): Promise<TrafficSnapshot[]>;
12
- }
13
- interface TrafficRecorderOptions {
14
- store: TrafficStore;
15
- sampleRate?: number;
16
- sanitize?: (snapshot: TrafficSnapshot) => TrafficSnapshot;
17
- }
18
- interface RecordOperationInput {
19
- operation: TrafficSnapshot['operation'];
20
- input: unknown;
21
- output?: unknown;
22
- error?: TrafficSnapshot['error'];
23
- success: boolean;
24
- durationMs?: number;
25
- tenantId?: string;
26
- userId?: string;
27
- channel?: string;
28
- metadata?: Record<string, unknown>;
29
- }
30
- declare class TrafficRecorder {
31
- private readonly store;
32
- private readonly sampleRate;
33
- private readonly sanitize?;
34
- constructor(options: TrafficRecorderOptions);
35
- record(input: RecordOperationInput): Promise<void>;
36
- private shouldSample;
37
- }
38
- //#endregion
39
- export { InMemoryTrafficStore, RecordOperationInput, TrafficRecorder, TrafficRecorderOptions, TrafficStore };
package/dist/types.d.ts DELETED
@@ -1,42 +0,0 @@
1
- import { ContractSpec, ResourceRefDescriptor } from "@lssm/lib.contracts";
2
- import { AnySchemaModel } from "@lssm/lib.schema";
3
-
4
- //#region src/types.d.ts
5
- interface TrafficSnapshot {
6
- id: string;
7
- operation: {
8
- name: string;
9
- version: number;
10
- };
11
- input: unknown;
12
- output?: unknown;
13
- error?: {
14
- name?: string;
15
- message?: string;
16
- stack?: string;
17
- code?: string;
18
- };
19
- success: boolean;
20
- timestamp: Date;
21
- durationMs?: number;
22
- tenantId?: string;
23
- userId?: string;
24
- channel?: string;
25
- metadata?: Record<string, unknown>;
26
- }
27
- interface GoldenTestCase {
28
- id: string;
29
- name: string;
30
- input: unknown;
31
- expectedOutput?: unknown;
32
- expectedError?: {
33
- name?: string;
34
- message?: string;
35
- code?: string;
36
- };
37
- success: boolean;
38
- metadata?: Record<string, unknown>;
39
- }
40
- type RuntimeContract = ContractSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>;
41
- //#endregion
42
- export { GoldenTestCase, RuntimeContract, TrafficSnapshot };