@aigne/test-utils 0.5.69-beta.9 → 0.5.69

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,178 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.69](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.25...test-utils-v0.5.69) (2026-01-16)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * The following workspace dependencies were updated
9
+ * dependencies
10
+ * @aigne/core bumped to 1.72.0
11
+
12
+ ## [0.5.69-beta.25](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.24...test-utils-v0.5.69-beta.25) (2026-01-16)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * bump version ([696560f](https://github.com/AIGNE-io/aigne-framework/commit/696560fa2673eddcb4d00ac0523fbbbde7273cb3))
18
+ * bump version ([70d217c](https://github.com/AIGNE-io/aigne-framework/commit/70d217c8360dd0dda7f5f17011c4e92ec836e801))
19
+ * bump version ([af04b69](https://github.com/AIGNE-io/aigne-framework/commit/af04b6931951afa35d52065430acc7fef4b10087))
20
+ * bump version ([ba7ad18](https://github.com/AIGNE-io/aigne-framework/commit/ba7ad184fcf32b49bf0507a3cb638d20fb00690d))
21
+ * bump version ([93a1c10](https://github.com/AIGNE-io/aigne-framework/commit/93a1c10cf35f88eaafe91092481f5d087bd5b3a9))
22
+ * 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))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @aigne/core bumped to 1.72.0-beta.25
30
+
31
+ ## [0.5.69-beta.24](https://github.com/AIGNE-io/aigne-framework/compare/test-utils-v0.5.69-beta.23...test-utils-v0.5.69-beta.24) (2026-01-16)
32
+
33
+
34
+ ### Dependencies
35
+
36
+ * The following workspace dependencies were updated
37
+ * dependencies
38
+ * @aigne/core bumped to 1.72.0-beta.24
39
+
40
+ ## [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)
41
+
42
+
43
+ ### Dependencies
44
+
45
+ * The following workspace dependencies were updated
46
+ * dependencies
47
+ * @aigne/core bumped to 1.72.0-beta.23
48
+
49
+ ## [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)
50
+
51
+
52
+ ### Dependencies
53
+
54
+ * The following workspace dependencies were updated
55
+ * dependencies
56
+ * @aigne/core bumped to 1.72.0-beta.22
57
+
58
+ ## [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)
59
+
60
+
61
+ ### Dependencies
62
+
63
+ * The following workspace dependencies were updated
64
+ * dependencies
65
+ * @aigne/core bumped to 1.72.0-beta.21
66
+
67
+ ## [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)
68
+
69
+
70
+ ### Dependencies
71
+
72
+ * The following workspace dependencies were updated
73
+ * dependencies
74
+ * @aigne/core bumped to 1.72.0-beta.20
75
+
76
+ ## [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)
77
+
78
+
79
+ ### Bug Fixes
80
+
81
+ * 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))
82
+
83
+
84
+ ### Dependencies
85
+
86
+ * The following workspace dependencies were updated
87
+ * dependencies
88
+ * @aigne/core bumped to 1.72.0-beta.19
89
+
90
+ ## [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)
91
+
92
+
93
+ ### Dependencies
94
+
95
+ * The following workspace dependencies were updated
96
+ * dependencies
97
+ * @aigne/core bumped to 1.72.0-beta.18
98
+
99
+ ## [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)
100
+
101
+
102
+ ### Dependencies
103
+
104
+ * The following workspace dependencies were updated
105
+ * dependencies
106
+ * @aigne/core bumped to 1.72.0-beta.17
107
+
108
+ ## [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)
109
+
110
+
111
+ ### Dependencies
112
+
113
+ * The following workspace dependencies were updated
114
+ * dependencies
115
+ * @aigne/core bumped to 1.72.0-beta.16
116
+
117
+ ## [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)
118
+
119
+
120
+ ### Dependencies
121
+
122
+ * The following workspace dependencies were updated
123
+ * dependencies
124
+ * @aigne/core bumped to 1.72.0-beta.15
125
+
126
+ ## [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)
127
+
128
+
129
+ ### Dependencies
130
+
131
+ * The following workspace dependencies were updated
132
+ * dependencies
133
+ * @aigne/core bumped to 1.72.0-beta.14
134
+
135
+ ## [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)
136
+
137
+
138
+ ### Bug Fixes
139
+
140
+ * bump version ([696560f](https://github.com/AIGNE-io/aigne-framework/commit/696560fa2673eddcb4d00ac0523fbbbde7273cb3))
141
+
142
+
143
+ ### Dependencies
144
+
145
+ * The following workspace dependencies were updated
146
+ * dependencies
147
+ * @aigne/core bumped to 1.72.0-beta.13
148
+
149
+ ## [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)
150
+
151
+
152
+ ### Dependencies
153
+
154
+ * The following workspace dependencies were updated
155
+ * dependencies
156
+ * @aigne/core bumped to 1.72.0-beta.12
157
+
158
+ ## [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)
159
+
160
+
161
+ ### Dependencies
162
+
163
+ * The following workspace dependencies were updated
164
+ * dependencies
165
+ * @aigne/core bumped to 1.72.0-beta.11
166
+
167
+ ## [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)
168
+
169
+
170
+ ### Dependencies
171
+
172
+ * The following workspace dependencies were updated
173
+ * dependencies
174
+ * @aigne/core bumped to 1.72.0-beta.10
175
+
3
176
  ## [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)
4
177
 
5
178
 
@@ -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.9",
3
+ "version": "0.5.69",
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.9"
30
+ "@aigne/core": "^1.72.0"
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"}