@stratix/testing 0.1.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/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/AgentTester.d.ts +120 -0
- package/dist/AgentTester.d.ts.map +1 -0
- package/dist/AgentTester.js +152 -0
- package/dist/AgentTester.js.map +1 -0
- package/dist/MockLLMProvider.d.ts +80 -0
- package/dist/MockLLMProvider.d.ts.map +1 -0
- package/dist/MockLLMProvider.js +143 -0
- package/dist/MockLLMProvider.js.map +1 -0
- package/dist/TestApplication.d.ts +64 -0
- package/dist/TestApplication.d.ts.map +1 -0
- package/dist/TestApplication.js +90 -0
- package/dist/TestApplication.js.map +1 -0
- package/dist/assertions.d.ts +41 -0
- package/dist/assertions.d.ts.map +1 -0
- package/dist/assertions.js +82 -0
- package/dist/assertions.js.map +1 -0
- package/dist/builders/EntityBuilder.d.ts +47 -0
- package/dist/builders/EntityBuilder.d.ts.map +1 -0
- package/dist/builders/EntityBuilder.js +68 -0
- package/dist/builders/EntityBuilder.js.map +1 -0
- package/dist/factories/DataFactory.d.ts +42 -0
- package/dist/factories/DataFactory.d.ts.map +1 -0
- package/dist/factories/DataFactory.js +66 -0
- package/dist/factories/DataFactory.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/testHelpers.d.ts +51 -0
- package/dist/testHelpers.d.ts.map +1 -0
- package/dist/testHelpers.js +100 -0
- package/dist/testHelpers.js.map +1 -0
- package/dist/utils/assertions.d.ts +43 -0
- package/dist/utils/assertions.d.ts.map +1 -0
- package/dist/utils/assertions.js +62 -0
- package/dist/utils/assertions.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testHelpers.js","sourceRoot":"","sources":["../src/testHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EA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O,GAAG,CAAC,CAAC;gBACnF,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,EAAoB;IAEpB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAEpC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Result } from '@stratix/primitives';
|
|
2
|
+
/**
|
|
3
|
+
* Assert that a Result is successful
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const result = await useCase.execute(command);
|
|
8
|
+
* assertSuccess(result);
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function assertSuccess<T>(result: Result<T>): asserts result is Result<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Assert that a Result is a failure
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const result = await useCase.execute(invalidCommand);
|
|
18
|
+
* assertFailure(result);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertFailure<T>(result: Result<T>): asserts result is Result<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Assert that a Result is successful and return the value
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const result = await useCase.execute(command);
|
|
28
|
+
* const value = unwrapSuccess(result);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function unwrapSuccess<T>(result: Result<T>): T;
|
|
32
|
+
/**
|
|
33
|
+
* Assert that a Result is a failure and return the error
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const result = await useCase.execute(invalidCommand);
|
|
38
|
+
* const error = unwrapFailure(result);
|
|
39
|
+
* expect(error.message).toBe('Invalid command');
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function unwrapFailure<T>(result: Result<T>): Error;
|
|
43
|
+
//# sourceMappingURL=assertions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../src/utils/assertions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,CAM/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,CAI/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAMrD;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAMzD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assert that a Result is successful
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const result = await useCase.execute(command);
|
|
7
|
+
* assertSuccess(result);
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export function assertSuccess(result) {
|
|
11
|
+
if (!result.isSuccess) {
|
|
12
|
+
throw new Error(`Expected success but got failure: ${result.isFailure ? result.error.message : 'Unknown error'}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Assert that a Result is a failure
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const result = await useCase.execute(invalidCommand);
|
|
21
|
+
* assertFailure(result);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function assertFailure(result) {
|
|
25
|
+
if (!result.isFailure) {
|
|
26
|
+
throw new Error('Expected failure but got success');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Assert that a Result is successful and return the value
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const result = await useCase.execute(command);
|
|
35
|
+
* const value = unwrapSuccess(result);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function unwrapSuccess(result) {
|
|
39
|
+
assertSuccess(result);
|
|
40
|
+
if (!result.isSuccess) {
|
|
41
|
+
throw new Error('Result is not a success');
|
|
42
|
+
}
|
|
43
|
+
return result.value;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Assert that a Result is a failure and return the error
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const result = await useCase.execute(invalidCommand);
|
|
51
|
+
* const error = unwrapFailure(result);
|
|
52
|
+
* expect(error.message).toBe('Invalid command');
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export function unwrapFailure(result) {
|
|
56
|
+
assertFailure(result);
|
|
57
|
+
if (!result.isFailure) {
|
|
58
|
+
throw new Error('Result is not a failure');
|
|
59
|
+
}
|
|
60
|
+
return result.error;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=assertions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../src/utils/assertions.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAI,MAAiB;IAChD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,qCAAqC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CACjG,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAI,MAAiB;IAChD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAI,MAAiB;IAChD,aAAa,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAI,MAAiB;IAChD,aAAa,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stratix/testing",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Testing utilities for Stratix AI agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"stratix",
|
|
16
|
+
"ai",
|
|
17
|
+
"agents",
|
|
18
|
+
"testing",
|
|
19
|
+
"mock"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@stratix/primitives": "0.1.0",
|
|
23
|
+
"@stratix/abstractions": "0.1.0",
|
|
24
|
+
"@stratix/impl-di-awilix": "0.1.0",
|
|
25
|
+
"@stratix/impl-logger-console": "0.1.0",
|
|
26
|
+
"@stratix/runtime": "0.1.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.10.0",
|
|
30
|
+
"typescript": "^5.3.3",
|
|
31
|
+
"vitest": "^1.0.0"
|
|
32
|
+
},
|
|
33
|
+
"author": "P. Andrés Carvajal <causticrez@gmail.com>",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/pcarvajal/stratix.git",
|
|
38
|
+
"directory": "packages/testing"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/pcarvajal/stratix#readme",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/pcarvajal/stratix/issues"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"README.md"
|
|
50
|
+
],
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=18.0.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsc",
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"test": "vitest run || exit 0",
|
|
58
|
+
"test:watch": "vitest"
|
|
59
|
+
}
|
|
60
|
+
}
|