@aigne/test-utils 0.5.69-beta.2 → 0.5.69-beta.23

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/CHANGELOG.md CHANGED
@@ -1,5 +1,204 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.69-beta.23](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.22...test-utils-v0.5.69-beta.23) (2026-01-15)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * The following workspace dependencies were updated
9
+ * dependencies
10
+ * @aigne/core bumped to 1.72.0-beta.23
11
+
12
+ ## [0.5.69-beta.22](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.21...test-utils-v0.5.69-beta.22) (2026-01-15)
13
+
14
+
15
+ ### Dependencies
16
+
17
+ * The following workspace dependencies were updated
18
+ * dependencies
19
+ * @aigne/core bumped to 1.72.0-beta.22
20
+
21
+ ## [0.5.69-beta.21](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.20...test-utils-v0.5.69-beta.21) (2026-01-15)
22
+
23
+
24
+ ### Dependencies
25
+
26
+ * The following workspace dependencies were updated
27
+ * dependencies
28
+ * @aigne/core bumped to 1.72.0-beta.21
29
+
30
+ ## [0.5.69-beta.20](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.19...test-utils-v0.5.69-beta.20) (2026-01-15)
31
+
32
+
33
+ ### Dependencies
34
+
35
+ * The following workspace dependencies were updated
36
+ * dependencies
37
+ * @aigne/core bumped to 1.72.0-beta.20
38
+
39
+ ## [0.5.69-beta.19](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.18...test-utils-v0.5.69-beta.19) (2026-01-14)
40
+
41
+
42
+ ### Bug Fixes
43
+
44
+ * improve test coverage tracking and reporting ([#903](https://github.com/AIGNE-io/aigne-framework/issues/903)) ([031144e](https://github.com/AIGNE-io/aigne-framework/commit/031144e74f29e882cffe52ffda8f7a18c76ace7f))
45
+
46
+
47
+ ### Dependencies
48
+
49
+ * The following workspace dependencies were updated
50
+ * dependencies
51
+ * @aigne/core bumped to 1.72.0-beta.19
52
+
53
+ ## [0.5.69-beta.18](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.17...test-utils-v0.5.69-beta.18) (2026-01-13)
54
+
55
+
56
+ ### Dependencies
57
+
58
+ * The following workspace dependencies were updated
59
+ * dependencies
60
+ * @aigne/core bumped to 1.72.0-beta.18
61
+
62
+ ## [0.5.69-beta.17](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.16...test-utils-v0.5.69-beta.17) (2026-01-12)
63
+
64
+
65
+ ### Dependencies
66
+
67
+ * The following workspace dependencies were updated
68
+ * dependencies
69
+ * @aigne/core bumped to 1.72.0-beta.17
70
+
71
+ ## [0.5.69-beta.16](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.15...test-utils-v0.5.69-beta.16) (2026-01-12)
72
+
73
+
74
+ ### Dependencies
75
+
76
+ * The following workspace dependencies were updated
77
+ * dependencies
78
+ * @aigne/core bumped to 1.72.0-beta.16
79
+
80
+ ## [0.5.69-beta.15](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.14...test-utils-v0.5.69-beta.15) (2026-01-10)
81
+
82
+
83
+ ### Dependencies
84
+
85
+ * The following workspace dependencies were updated
86
+ * dependencies
87
+ * @aigne/core bumped to 1.72.0-beta.15
88
+
89
+ ## [0.5.69-beta.14](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.13...test-utils-v0.5.69-beta.14) (2026-01-09)
90
+
91
+
92
+ ### Dependencies
93
+
94
+ * The following workspace dependencies were updated
95
+ * dependencies
96
+ * @aigne/core bumped to 1.72.0-beta.14
97
+
98
+ ## [0.5.69-beta.13](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.12...test-utils-v0.5.69-beta.13) (2026-01-08)
99
+
100
+
101
+ ### Bug Fixes
102
+
103
+ * bump version ([696560f](https://github.com/AIGNE-io/aigne-framework/commit/696560fa2673eddcb4d00ac0523fbbbde7273cb3))
104
+
105
+
106
+ ### Dependencies
107
+
108
+ * The following workspace dependencies were updated
109
+ * dependencies
110
+ * @aigne/core bumped to 1.72.0-beta.13
111
+
112
+ ## [0.5.69-beta.12](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.11...test-utils-v0.5.69-beta.12) (2026-01-07)
113
+
114
+
115
+ ### Dependencies
116
+
117
+ * The following workspace dependencies were updated
118
+ * dependencies
119
+ * @aigne/core bumped to 1.72.0-beta.12
120
+
121
+ ## [0.5.69-beta.11](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.10...test-utils-v0.5.69-beta.11) (2026-01-06)
122
+
123
+
124
+ ### Dependencies
125
+
126
+ * The following workspace dependencies were updated
127
+ * dependencies
128
+ * @aigne/core bumped to 1.72.0-beta.11
129
+
130
+ ## [0.5.69-beta.10](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.9...test-utils-v0.5.69-beta.10) (2026-01-06)
131
+
132
+
133
+ ### Dependencies
134
+
135
+ * The following workspace dependencies were updated
136
+ * dependencies
137
+ * @aigne/core bumped to 1.72.0-beta.10
138
+
139
+ ## [0.5.69-beta.9](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.8...test-utils-v0.5.69-beta.9) (2026-01-02)
140
+
141
+
142
+ ### Dependencies
143
+
144
+ * The following workspace dependencies were updated
145
+ * dependencies
146
+ * @aigne/core bumped to 1.72.0-beta.9
147
+
148
+ ## [0.5.69-beta.8](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.7...test-utils-v0.5.69-beta.8) (2025-12-31)
149
+
150
+
151
+ ### Dependencies
152
+
153
+ * The following workspace dependencies were updated
154
+ * dependencies
155
+ * @aigne/core bumped to 1.72.0-beta.8
156
+
157
+ ## [0.5.69-beta.7](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.6...test-utils-v0.5.69-beta.7) (2025-12-26)
158
+
159
+
160
+ ### Dependencies
161
+
162
+ * The following workspace dependencies were updated
163
+ * dependencies
164
+ * @aigne/core bumped to 1.72.0-beta.7
165
+
166
+ ## [0.5.69-beta.6](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.5...test-utils-v0.5.69-beta.6) (2025-12-25)
167
+
168
+
169
+ ### Dependencies
170
+
171
+ * The following workspace dependencies were updated
172
+ * dependencies
173
+ * @aigne/core bumped to 1.72.0-beta.6
174
+
175
+ ## [0.5.69-beta.5](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.4...test-utils-v0.5.69-beta.5) (2025-12-25)
176
+
177
+
178
+ ### Dependencies
179
+
180
+ * The following workspace dependencies were updated
181
+ * dependencies
182
+ * @aigne/core bumped to 1.72.0-beta.5
183
+
184
+ ## [0.5.69-beta.4](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.3...test-utils-v0.5.69-beta.4) (2025-12-24)
185
+
186
+
187
+ ### Dependencies
188
+
189
+ * The following workspace dependencies were updated
190
+ * dependencies
191
+ * @aigne/core bumped to 1.72.0-beta.4
192
+
193
+ ## [0.5.69-beta.3](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.2...test-utils-v0.5.69-beta.3) (2025-12-19)
194
+
195
+
196
+ ### Dependencies
197
+
198
+ * The following workspace dependencies were updated
199
+ * dependencies
200
+ * @aigne/core bumped to 1.72.0-beta.3
201
+
3
202
  ## [0.5.69-beta.2](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.1...test-utils-v0.5.69-beta.2) (2025-12-19)
4
203
 
5
204
 
@@ -0,0 +1,38 @@
1
+ export interface ImportAllModulesOptions {
2
+ /**
3
+ * The root directory to scan for source files
4
+ */
5
+ sourceDir: string;
6
+ /**
7
+ * Patterns to exclude from import (default: test files, type definitions, build artifacts)
8
+ */
9
+ exclude?: string[];
10
+ /**
11
+ * File extensions to include (default: ts, tsx, js, jsx, mjs, cjs)
12
+ */
13
+ extensions?: string[];
14
+ /**
15
+ * Whether to show verbose logging (default: false)
16
+ */
17
+ verbose?: boolean;
18
+ }
19
+ /**
20
+ * Import all modules in a directory for coverage tracking.
21
+ *
22
+ * This utility dynamically imports all source files in a package to ensure
23
+ * Bun's coverage reporter includes them in coverage metrics, even if they
24
+ * aren't directly imported by any tests.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * import { test } from 'bun:test';
29
+ * import { importAllModules } from '@aigne/test-utils/utils/import-all-modules';
30
+ *
31
+ * test('import all modules for coverage tracking', async () => {
32
+ * await importAllModules({
33
+ * sourceDir: '../src',
34
+ * });
35
+ * });
36
+ * ```
37
+ */
38
+ export declare function importAllModules(options: ImportAllModulesOptions): Promise<void>;
@@ -0,0 +1,84 @@
1
+ import { join, resolve } from "node:path";
2
+ import { Glob } from "bun";
3
+ /**
4
+ * Import all modules in a directory for coverage tracking.
5
+ *
6
+ * This utility dynamically imports all source files in a package to ensure
7
+ * Bun's coverage reporter includes them in coverage metrics, even if they
8
+ * aren't directly imported by any tests.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { test } from 'bun:test';
13
+ * import { importAllModules } from '@aigne/test-utils/utils/import-all-modules';
14
+ *
15
+ * test('import all modules for coverage tracking', async () => {
16
+ * await importAllModules({
17
+ * sourceDir: '../src',
18
+ * });
19
+ * });
20
+ * ```
21
+ */
22
+ export async function importAllModules(options) {
23
+ const { sourceDir, exclude = [
24
+ "**/*.test.*",
25
+ "**/*.spec.*",
26
+ "**/__tests__/**",
27
+ "**/__mocks__/**",
28
+ "**/*.d.ts",
29
+ "**/node_modules/**",
30
+ "**/lib/**",
31
+ "**/dist/**",
32
+ "**/coverage/**",
33
+ ], extensions = ["ts", "tsx", "js", "jsx", "mjs", "cjs"], verbose = false, } = options;
34
+ // Resolve sourceDir to absolute path from current working directory
35
+ const absoluteSourceDir = resolve(sourceDir);
36
+ // Build the glob pattern for matching files
37
+ const pattern = extensions.length === 1 ? `**/*.${extensions[0]}` : `**/*.{${extensions.join(",")}}`;
38
+ const glob = new Glob(pattern);
39
+ // Scan for files
40
+ const files = [];
41
+ for await (const file of glob.scan({
42
+ cwd: absoluteSourceDir,
43
+ onlyFiles: true,
44
+ })) {
45
+ // Check if file should be excluded
46
+ const shouldExclude = exclude.some((pattern) => {
47
+ // Simple pattern matching (supports ** and * wildcards)
48
+ const regexPattern = pattern
49
+ .replace(/\*\*/g, ".*")
50
+ .replace(/\*/g, "[^/]*")
51
+ .replace(/\./g, "\\.");
52
+ return new RegExp(regexPattern).test(file);
53
+ });
54
+ if (!shouldExclude) {
55
+ files.push(file);
56
+ }
57
+ }
58
+ if (verbose) {
59
+ console.log(`[coverage] Found ${files.length} source files to import`);
60
+ }
61
+ // Import all files in parallel
62
+ const imports = files.map(async (file) => {
63
+ const absoluteFilePath = join(absoluteSourceDir, file);
64
+ try {
65
+ // Use file:// URL for reliable imports across different CWDs
66
+ const fileUrl = `file://${absoluteFilePath}`;
67
+ await import(fileUrl);
68
+ if (verbose) {
69
+ console.log(`[coverage] ✓ Imported: ${file}`);
70
+ }
71
+ }
72
+ catch (error) {
73
+ // Some files may fail to import (e.g., templates, type-only files)
74
+ // This is expected and should not fail the test
75
+ if (verbose) {
76
+ console.warn(`[coverage] ⚠ Failed to import ${file}:`, error);
77
+ }
78
+ }
79
+ });
80
+ await Promise.allSettled(imports);
81
+ if (verbose) {
82
+ console.log(`[coverage] Completed importing ${files.length} modules`);
83
+ }
84
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/test-utils",
3
- "version": "0.5.69-beta.2",
3
+ "version": "0.5.69-beta.23",
4
4
  "description": "Test utils for AIGNE framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,7 +27,7 @@
27
27
  }
28
28
  },
29
29
  "dependencies": {
30
- "@aigne/core": "^1.72.0-beta.2"
30
+ "@aigne/core": "^1.72.0-beta.23"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/bun": "^1.2.22",
@@ -0,0 +1,121 @@
1
+ import { join, resolve } from "node:path";
2
+ import { Glob } from "bun";
3
+
4
+ export interface ImportAllModulesOptions {
5
+ /**
6
+ * The root directory to scan for source files
7
+ */
8
+ sourceDir: string;
9
+
10
+ /**
11
+ * Patterns to exclude from import (default: test files, type definitions, build artifacts)
12
+ */
13
+ exclude?: string[];
14
+
15
+ /**
16
+ * File extensions to include (default: ts, tsx, js, jsx, mjs, cjs)
17
+ */
18
+ extensions?: string[];
19
+
20
+ /**
21
+ * Whether to show verbose logging (default: false)
22
+ */
23
+ verbose?: boolean;
24
+ }
25
+
26
+ /**
27
+ * Import all modules in a directory for coverage tracking.
28
+ *
29
+ * This utility dynamically imports all source files in a package to ensure
30
+ * Bun's coverage reporter includes them in coverage metrics, even if they
31
+ * aren't directly imported by any tests.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * import { test } from 'bun:test';
36
+ * import { importAllModules } from '@aigne/test-utils/utils/import-all-modules';
37
+ *
38
+ * test('import all modules for coverage tracking', async () => {
39
+ * await importAllModules({
40
+ * sourceDir: '../src',
41
+ * });
42
+ * });
43
+ * ```
44
+ */
45
+ export async function importAllModules(options: ImportAllModulesOptions): Promise<void> {
46
+ const {
47
+ sourceDir,
48
+ exclude = [
49
+ "**/*.test.*",
50
+ "**/*.spec.*",
51
+ "**/__tests__/**",
52
+ "**/__mocks__/**",
53
+ "**/*.d.ts",
54
+ "**/node_modules/**",
55
+ "**/lib/**",
56
+ "**/dist/**",
57
+ "**/coverage/**",
58
+ ],
59
+ extensions = ["ts", "tsx", "js", "jsx", "mjs", "cjs"],
60
+ verbose = false,
61
+ } = options;
62
+
63
+ // Resolve sourceDir to absolute path from current working directory
64
+ const absoluteSourceDir = resolve(sourceDir);
65
+
66
+ // Build the glob pattern for matching files
67
+ const pattern =
68
+ extensions.length === 1 ? `**/*.${extensions[0]}` : `**/*.{${extensions.join(",")}}`;
69
+
70
+ const glob = new Glob(pattern);
71
+
72
+ // Scan for files
73
+ const files: string[] = [];
74
+ for await (const file of glob.scan({
75
+ cwd: absoluteSourceDir,
76
+ onlyFiles: true,
77
+ })) {
78
+ // Check if file should be excluded
79
+ const shouldExclude = exclude.some((pattern) => {
80
+ // Simple pattern matching (supports ** and * wildcards)
81
+ const regexPattern = pattern
82
+ .replace(/\*\*/g, ".*")
83
+ .replace(/\*/g, "[^/]*")
84
+ .replace(/\./g, "\\.");
85
+ return new RegExp(regexPattern).test(file);
86
+ });
87
+
88
+ if (!shouldExclude) {
89
+ files.push(file);
90
+ }
91
+ }
92
+
93
+ if (verbose) {
94
+ console.log(`[coverage] Found ${files.length} source files to import`);
95
+ }
96
+
97
+ // Import all files in parallel
98
+ const imports = files.map(async (file) => {
99
+ const absoluteFilePath = join(absoluteSourceDir, file);
100
+ try {
101
+ // Use file:// URL for reliable imports across different CWDs
102
+ const fileUrl = `file://${absoluteFilePath}`;
103
+ await import(fileUrl);
104
+ if (verbose) {
105
+ console.log(`[coverage] ✓ Imported: ${file}`);
106
+ }
107
+ } catch (error) {
108
+ // Some files may fail to import (e.g., templates, type-only files)
109
+ // This is expected and should not fail the test
110
+ if (verbose) {
111
+ console.warn(`[coverage] ⚠ Failed to import ${file}:`, error);
112
+ }
113
+ }
114
+ });
115
+
116
+ await Promise.allSettled(imports);
117
+
118
+ if (verbose) {
119
+ console.log(`[coverage] Completed importing ${files.length} modules`);
120
+ }
121
+ }
@@ -4,6 +4,7 @@
4
4
  "rootDir": "./src",
5
5
  "outDir": "./lib",
6
6
  "noEmit": false,
7
+ "allowImportingTsExtensions": false,
7
8
  "declaration": true
8
9
  },
9
10
  "include": ["./src"]
@@ -1 +1 @@
1
- {"root":["./src/run-example-test.ts","./src/utils/agent-response.ts","./src/utils/event-stream.ts","./src/utils/openai-like-utils.ts","./src/utils/with-env.ts"],"version":"5.9.2"}
1
+ {"root":["./src/run-example-test.ts","./src/utils/agent-response.ts","./src/utils/event-stream.ts","./src/utils/import-all-modules.ts","./src/utils/openai-like-utils.ts","./src/utils/with-env.ts"],"version":"5.9.2"}