pi-lens 3.6.3 → 3.6.4

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.
Files changed (206) hide show
  1. package/package.json +3 -3
  2. package/tsconfig.json +1 -1
  3. package/clients/__tests__/file-time.test.js +0 -216
  4. package/clients/__tests__/file-time.test.ts +0 -276
  5. package/clients/__tests__/format-service.test.js +0 -245
  6. package/clients/__tests__/format-service.test.ts +0 -339
  7. package/clients/__tests__/formatters.test.js +0 -271
  8. package/clients/__tests__/formatters.test.ts +0 -401
  9. package/clients/agent-behavior-client.js +0 -110
  10. package/clients/agent-behavior-client.test.js +0 -94
  11. package/clients/agent-behavior-client.test.ts +0 -116
  12. package/clients/amain-types.js +0 -164
  13. package/clients/architect-client.js +0 -291
  14. package/clients/ast-grep-client.js +0 -253
  15. package/clients/ast-grep-parser.js +0 -84
  16. package/clients/ast-grep-rule-manager.js +0 -89
  17. package/clients/ast-grep-types.js +0 -9
  18. package/clients/auto-loop.js +0 -131
  19. package/clients/biome-client.js +0 -420
  20. package/clients/biome-client.test.js +0 -144
  21. package/clients/biome-client.test.ts +0 -163
  22. package/clients/cache/rule-cache.js +0 -72
  23. package/clients/cache-manager.js +0 -245
  24. package/clients/cache-manager.test.js +0 -197
  25. package/clients/cache-manager.test.ts +0 -299
  26. package/clients/complexity-client.js +0 -675
  27. package/clients/complexity-client.test.js +0 -234
  28. package/clients/complexity-client.test.ts +0 -255
  29. package/clients/config-validator.js +0 -465
  30. package/clients/dependency-checker.js +0 -325
  31. package/clients/dependency-checker.test.js +0 -60
  32. package/clients/dependency-checker.test.ts +0 -71
  33. package/clients/dispatch/__tests__/autofix-integration.test.js +0 -245
  34. package/clients/dispatch/__tests__/autofix-integration.test.ts +0 -300
  35. package/clients/dispatch/__tests__/runner-registration.test.js +0 -234
  36. package/clients/dispatch/__tests__/runner-registration.test.ts +0 -286
  37. package/clients/dispatch/debug.log +0 -1
  38. package/clients/dispatch/dispatcher.edge.test.js +0 -82
  39. package/clients/dispatch/dispatcher.edge.test.ts +0 -100
  40. package/clients/dispatch/dispatcher.format.test.js +0 -46
  41. package/clients/dispatch/dispatcher.format.test.ts +0 -58
  42. package/clients/dispatch/dispatcher.inline.test.js +0 -74
  43. package/clients/dispatch/dispatcher.inline.test.ts +0 -93
  44. package/clients/dispatch/dispatcher.js +0 -381
  45. package/clients/dispatch/dispatcher.test.js +0 -116
  46. package/clients/dispatch/dispatcher.test.ts +0 -149
  47. package/clients/dispatch/integration.js +0 -108
  48. package/clients/dispatch/plan.js +0 -183
  49. package/clients/dispatch/runners/architect.js +0 -83
  50. package/clients/dispatch/runners/architect.test.js +0 -138
  51. package/clients/dispatch/runners/architect.test.ts +0 -162
  52. package/clients/dispatch/runners/ast-grep-napi.js +0 -405
  53. package/clients/dispatch/runners/ast-grep-napi.test.js +0 -107
  54. package/clients/dispatch/runners/ast-grep-napi.test.ts +0 -129
  55. package/clients/dispatch/runners/ast-grep.js +0 -157
  56. package/clients/dispatch/runners/biome.js +0 -55
  57. package/clients/dispatch/runners/config-validation.js +0 -67
  58. package/clients/dispatch/runners/go-vet.js +0 -48
  59. package/clients/dispatch/runners/index.js +0 -47
  60. package/clients/dispatch/runners/lsp.js +0 -102
  61. package/clients/dispatch/runners/oxlint.js +0 -67
  62. package/clients/dispatch/runners/oxlint.test.js +0 -230
  63. package/clients/dispatch/runners/oxlint.test.ts +0 -303
  64. package/clients/dispatch/runners/pyright.js +0 -100
  65. package/clients/dispatch/runners/pyright.test.js +0 -98
  66. package/clients/dispatch/runners/pyright.test.ts +0 -121
  67. package/clients/dispatch/runners/python-slop.js +0 -97
  68. package/clients/dispatch/runners/python-slop.test.js +0 -203
  69. package/clients/dispatch/runners/python-slop.test.ts +0 -298
  70. package/clients/dispatch/runners/ruff.js +0 -48
  71. package/clients/dispatch/runners/rust-clippy.js +0 -102
  72. package/clients/dispatch/runners/scan_codebase.test.js +0 -89
  73. package/clients/dispatch/runners/scan_codebase.test.ts +0 -105
  74. package/clients/dispatch/runners/shellcheck.js +0 -147
  75. package/clients/dispatch/runners/shellcheck.test.js +0 -98
  76. package/clients/dispatch/runners/shellcheck.test.ts +0 -129
  77. package/clients/dispatch/runners/similarity.js +0 -230
  78. package/clients/dispatch/runners/spellcheck.js +0 -106
  79. package/clients/dispatch/runners/spellcheck.test.js +0 -158
  80. package/clients/dispatch/runners/spellcheck.test.ts +0 -214
  81. package/clients/dispatch/runners/tree-sitter.js +0 -246
  82. package/clients/dispatch/runners/ts-lsp.js +0 -125
  83. package/clients/dispatch/runners/ts-slop.js +0 -113
  84. package/clients/dispatch/runners/type-safety.js +0 -142
  85. package/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -134
  86. package/clients/dispatch/runners/utils/runner-helpers.js +0 -115
  87. package/clients/dispatch/runners/utils.js +0 -51
  88. package/clients/dispatch/runners/yaml-rule-parser.js +0 -360
  89. package/clients/dispatch/types.js +0 -16
  90. package/clients/dispatch/utils/format-utils.js +0 -44
  91. package/clients/dogfood.test.js +0 -201
  92. package/clients/dogfood.test.ts +0 -269
  93. package/clients/file-kinds.js +0 -177
  94. package/clients/file-kinds.test.js +0 -169
  95. package/clients/file-kinds.test.ts +0 -210
  96. package/clients/file-time.js +0 -152
  97. package/clients/file-utils.js +0 -40
  98. package/clients/fix-scanners.js +0 -204
  99. package/clients/format-service.js +0 -184
  100. package/clients/formatters.js +0 -488
  101. package/clients/go-client.js +0 -203
  102. package/clients/go-client.test.js +0 -127
  103. package/clients/go-client.test.ts +0 -143
  104. package/clients/installer/index.js +0 -403
  105. package/clients/interviewer-templates.js +0 -75
  106. package/clients/interviewer.js +0 -173
  107. package/clients/jscpd-client.js +0 -196
  108. package/clients/jscpd-client.test.js +0 -127
  109. package/clients/jscpd-client.test.ts +0 -145
  110. package/clients/knip-client.js +0 -239
  111. package/clients/knip-client.test.js +0 -112
  112. package/clients/knip-client.test.ts +0 -128
  113. package/clients/latency-logger.js +0 -40
  114. package/clients/lsp/__tests__/client.test.js +0 -310
  115. package/clients/lsp/__tests__/client.test.ts +0 -412
  116. package/clients/lsp/__tests__/config.test.js +0 -167
  117. package/clients/lsp/__tests__/config.test.ts +0 -217
  118. package/clients/lsp/__tests__/error-recovery.test.js +0 -213
  119. package/clients/lsp/__tests__/error-recovery.test.ts +0 -279
  120. package/clients/lsp/__tests__/integration.test.js +0 -127
  121. package/clients/lsp/__tests__/integration.test.ts +0 -160
  122. package/clients/lsp/__tests__/launch.test.js +0 -313
  123. package/clients/lsp/__tests__/launch.test.ts +0 -394
  124. package/clients/lsp/__tests__/server.test.js +0 -259
  125. package/clients/lsp/__tests__/server.test.ts +0 -332
  126. package/clients/lsp/__tests__/service.test.js +0 -438
  127. package/clients/lsp/__tests__/service.test.ts +0 -530
  128. package/clients/lsp/client.js +0 -350
  129. package/clients/lsp/config.js +0 -112
  130. package/clients/lsp/index.js +0 -318
  131. package/clients/lsp/installer/index.js +0 -391
  132. package/clients/lsp/interactive-install.js +0 -221
  133. package/clients/lsp/language.js +0 -170
  134. package/clients/lsp/launch.js +0 -329
  135. package/clients/lsp/lsp/launch.js +0 -116
  136. package/clients/lsp/lsp/server.js +0 -532
  137. package/clients/lsp/lsp-index.js +0 -10
  138. package/clients/lsp/path-utils.js +0 -5
  139. package/clients/lsp/server.js +0 -725
  140. package/clients/lsp/test-py-spawn/requirements.txt +0 -1
  141. package/clients/lsp/test-py-spawn/test.py +0 -3
  142. package/clients/lsp/test-py-svc/requirements.txt +0 -1
  143. package/clients/lsp/test-py-svc/test.py +0 -3
  144. package/clients/lsp/test-python-project/requirements.txt +0 -1
  145. package/clients/lsp/test-python-project/test.py +0 -5
  146. package/clients/metrics-client.js +0 -107
  147. package/clients/metrics-client.test.js +0 -128
  148. package/clients/metrics-client.test.ts +0 -163
  149. package/clients/metrics-history.js +0 -367
  150. package/clients/path-utils.js +0 -142
  151. package/clients/pipeline.js +0 -272
  152. package/clients/production-readiness.js +0 -522
  153. package/clients/project-index.js +0 -255
  154. package/clients/project-metadata.js +0 -531
  155. package/clients/ruff-client.js +0 -325
  156. package/clients/ruff-client.test.js +0 -132
  157. package/clients/ruff-client.test.ts +0 -153
  158. package/clients/rules-scanner.js +0 -97
  159. package/clients/runner-tracker.js +0 -152
  160. package/clients/rust-client.js +0 -205
  161. package/clients/rust-client.test.js +0 -108
  162. package/clients/rust-client.test.ts +0 -130
  163. package/clients/safe-spawn-async.js +0 -163
  164. package/clients/safe-spawn.js +0 -241
  165. package/clients/sanitize.js +0 -291
  166. package/clients/sanitize.test.js +0 -177
  167. package/clients/sanitize.test.ts +0 -223
  168. package/clients/scan-architectural-debt.js +0 -167
  169. package/clients/scan-utils.js +0 -83
  170. package/clients/secrets-scanner.js +0 -119
  171. package/clients/secrets-scanner.test.js +0 -100
  172. package/clients/secrets-scanner.test.ts +0 -113
  173. package/clients/sg-runner.js +0 -292
  174. package/clients/state-matrix.js +0 -160
  175. package/clients/subprocess-client.js +0 -65
  176. package/clients/symbol-types.js +0 -5
  177. package/clients/test-runner-client.js +0 -523
  178. package/clients/test-runner-client.test.js +0 -192
  179. package/clients/test-runner-client.test.ts +0 -253
  180. package/clients/test-utils.js +0 -27
  181. package/clients/test-utils.ts +0 -36
  182. package/clients/todo-scanner.js +0 -200
  183. package/clients/todo-scanner.test.js +0 -301
  184. package/clients/todo-scanner.test.ts +0 -352
  185. package/clients/tool-availability.js +0 -207
  186. package/clients/tree-sitter-client.js +0 -601
  187. package/clients/tree-sitter-query-loader.js +0 -355
  188. package/clients/tree-sitter-symbol-extractor.js +0 -289
  189. package/clients/ts-service.js +0 -129
  190. package/clients/type-coverage-client.js +0 -127
  191. package/clients/type-coverage-client.test.js +0 -105
  192. package/clients/type-coverage-client.test.ts +0 -125
  193. package/clients/type-safety-client.js +0 -138
  194. package/clients/types.js +0 -11
  195. package/clients/typescript-client.codefix.test.js +0 -157
  196. package/clients/typescript-client.codefix.test.ts +0 -186
  197. package/clients/typescript-client.js +0 -509
  198. package/clients/typescript-client.test.js +0 -105
  199. package/clients/typescript-client.test.ts +0 -126
  200. package/commands/booboo.js +0 -1007
  201. package/commands/fix-from-booboo.js +0 -398
  202. package/commands/fix-simplified.js +0 -618
  203. package/commands/rate.js +0 -281
  204. package/commands/rate.test.js +0 -119
  205. package/commands/rate.test.ts +0 -131
  206. package/commands/refactor.js +0 -130
@@ -1,192 +0,0 @@
1
- import * as path from "node:path";
2
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
3
- import { TestRunnerClient } from "./test-runner-client.js";
4
- import { createTempFile, setupTestEnvironment } from "./test-utils.js";
5
- describe("TestRunnerClient", () => {
6
- let client;
7
- let tmpDir;
8
- let cleanup;
9
- beforeEach(() => {
10
- client = new TestRunnerClient();
11
- ({ tmpDir, cleanup } = setupTestEnvironment("pi-lens-test-runner-"));
12
- });
13
- afterEach(() => {
14
- cleanup();
15
- });
16
- afterEach(() => {
17
- cleanup();
18
- });
19
- describe("detectRunner", () => {
20
- it("should detect vitest from config file", () => {
21
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
22
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
23
- const result = client.detectRunner(tmpDir);
24
- expect(result).not.toBeNull();
25
- expect(result?.runner).toBe("vitest");
26
- });
27
- it("should detect jest from config file", () => {
28
- createTempFile(tmpDir, "jest.config.js", "module.exports = {}");
29
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
30
- const result = client.detectRunner(tmpDir);
31
- expect(result).not.toBeNull();
32
- expect(result?.runner).toBe("jest");
33
- });
34
- it("should detect pytest from config file", () => {
35
- createTempFile(tmpDir, "pytest.ini", "[tool:pytest]");
36
- createTempFile(tmpDir, "src/app.py", "x = 1");
37
- const result = client.detectRunner(tmpDir);
38
- expect(result).not.toBeNull();
39
- expect(result?.runner).toBe("pytest");
40
- });
41
- it("should detect runner from node_modules", () => {
42
- // Create a node_modules/vitest to simulate installed package
43
- createTempFile(tmpDir, "node_modules/vitest/package.json", "{}");
44
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
45
- const result = client.detectRunner(tmpDir);
46
- // Should detect vitest from node_modules
47
- expect(result).not.toBeNull();
48
- });
49
- it("should prefer vitest over jest when both exist", () => {
50
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
51
- createTempFile(tmpDir, "jest.config.js", "module.exports = {}");
52
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
53
- const result = client.detectRunner(tmpDir);
54
- expect(result?.runner).toBe("vitest");
55
- });
56
- });
57
- describe("findTestFile", () => {
58
- it("should find test file with .test.ts suffix", () => {
59
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
60
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
61
- createTempFile(tmpDir, "src/app.test.ts", "describe('app', () => {});");
62
- const result = client.findTestFile(path.join(tmpDir, "src/app.ts"), tmpDir);
63
- expect(result).not.toBeNull();
64
- expect(result?.testFile).toContain("app.test.ts");
65
- expect(result?.runner).toBe("vitest");
66
- });
67
- it("should find test file with .spec.ts suffix", () => {
68
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
69
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
70
- createTempFile(tmpDir, "src/app.spec.ts", "describe('app', () => {});");
71
- const result = client.findTestFile(path.join(tmpDir, "src/app.ts"), tmpDir);
72
- expect(result).not.toBeNull();
73
- expect(result?.testFile).toContain("app.spec.ts");
74
- });
75
- it("should find test file in __tests__ directory", () => {
76
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
77
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
78
- createTempFile(tmpDir, "src/__tests__/app.test.ts", "describe('app', () => {});");
79
- const result = client.findTestFile(path.join(tmpDir, "src/app.ts"), tmpDir);
80
- expect(result).not.toBeNull();
81
- expect(result?.testFile).toContain("__tests__");
82
- });
83
- it("should find test file in top-level tests/ directory", () => {
84
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
85
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
86
- createTempFile(tmpDir, "tests/app.test.ts", "describe('app', () => {});");
87
- const result = client.findTestFile(path.join(tmpDir, "src/app.ts"), tmpDir);
88
- expect(result).not.toBeNull();
89
- expect(result?.testFile).toContain(path.join("tests", "app.test.ts"));
90
- });
91
- it("should find pytest test file with test_ prefix", () => {
92
- createTempFile(tmpDir, "pytest.ini", "[tool:pytest]");
93
- createTempFile(tmpDir, "src/app.py", "x = 1");
94
- createTempFile(tmpDir, "tests/test_app.py", "def test_app(): pass");
95
- const result = client.findTestFile(path.join(tmpDir, "src/app.py"), tmpDir);
96
- expect(result).not.toBeNull();
97
- expect(result?.testFile).toContain("test_app.py");
98
- expect(result?.runner).toBe("pytest");
99
- });
100
- it("should return null when no test file found", () => {
101
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
102
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
103
- const result = client.findTestFile(path.join(tmpDir, "src/app.ts"), tmpDir);
104
- expect(result).toBeNull();
105
- });
106
- it("should find test file even without config (if runner installed)", () => {
107
- // Simulate vitest installed in node_modules
108
- createTempFile(tmpDir, "node_modules/vitest/package.json", "{}");
109
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
110
- createTempFile(tmpDir, "src/app.test.ts", "describe('app', () => {});");
111
- const result = client.findTestFile(path.join(tmpDir, "src/app.ts"), tmpDir);
112
- // Should find the test file since vitest is "installed"
113
- expect(result).not.toBeNull();
114
- });
115
- });
116
- describe("formatResult", () => {
117
- it("should format passing tests", () => {
118
- const result = {
119
- file: "/test/app.test.ts",
120
- sourceFile: "/test/app.ts",
121
- runner: "vitest",
122
- passed: 5,
123
- failed: 0,
124
- skipped: 0,
125
- failures: [],
126
- duration: 420,
127
- };
128
- const formatted = client.formatResult(result);
129
- expect(formatted).toContain("✓");
130
- expect(formatted).toContain("5/5 passed");
131
- expect(formatted).toContain("0.42s");
132
- });
133
- it("should format failing tests", () => {
134
- const result = {
135
- file: "/test/app.test.ts",
136
- sourceFile: "/test/app.ts",
137
- runner: "vitest",
138
- passed: 3,
139
- failed: 2,
140
- skipped: 0,
141
- failures: [
142
- {
143
- name: "should add",
144
- message: "expected 4, got 3",
145
- location: "app.test.ts:10",
146
- },
147
- {
148
- name: "should subtract",
149
- message: "expected 1, got 2",
150
- location: "app.test.ts:20",
151
- },
152
- ],
153
- duration: 420,
154
- };
155
- const formatted = client.formatResult(result);
156
- expect(formatted).toContain("✗");
157
- expect(formatted).toContain("2/5 failed");
158
- expect(formatted).toContain("should add");
159
- expect(formatted).toContain("should subtract");
160
- });
161
- it("should format runner errors", () => {
162
- const result = {
163
- file: "/test/app.test.ts",
164
- sourceFile: "/test/app.ts",
165
- runner: "vitest",
166
- passed: 0,
167
- failed: 0,
168
- skipped: 0,
169
- failures: [],
170
- duration: 0,
171
- error: "Test file not found",
172
- };
173
- const formatted = client.formatResult(result);
174
- expect(formatted).toContain("⚠");
175
- expect(formatted).toContain("Could not run tests");
176
- });
177
- it("should return empty string for no tests", () => {
178
- const result = {
179
- file: "/test/app.test.ts",
180
- sourceFile: "/test/app.ts",
181
- runner: "vitest",
182
- passed: 0,
183
- failed: 0,
184
- skipped: 0,
185
- failures: [],
186
- duration: 0,
187
- };
188
- const formatted = client.formatResult(result);
189
- expect(formatted).toBe("");
190
- });
191
- });
192
- });
@@ -1,253 +0,0 @@
1
- import * as path from "node:path";
2
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
3
- import { TestRunnerClient } from "./test-runner-client.js";
4
- import { createTempFile, setupTestEnvironment } from "./test-utils.js";
5
-
6
- describe("TestRunnerClient", () => {
7
- let client: TestRunnerClient;
8
- let tmpDir: string;
9
- let cleanup: () => void;
10
-
11
- beforeEach(() => {
12
- client = new TestRunnerClient();
13
- ({ tmpDir, cleanup } = setupTestEnvironment("pi-lens-test-runner-"));
14
- });
15
-
16
- afterEach(() => {
17
- cleanup();
18
- });
19
-
20
- afterEach(() => {
21
- cleanup();
22
- });
23
-
24
- describe("detectRunner", () => {
25
- it("should detect vitest from config file", () => {
26
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
27
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
28
-
29
- const result = client.detectRunner(tmpDir);
30
- expect(result).not.toBeNull();
31
- expect(result?.runner).toBe("vitest");
32
- });
33
-
34
- it("should detect jest from config file", () => {
35
- createTempFile(tmpDir, "jest.config.js", "module.exports = {}");
36
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
37
-
38
- const result = client.detectRunner(tmpDir);
39
- expect(result).not.toBeNull();
40
- expect(result?.runner).toBe("jest");
41
- });
42
-
43
- it("should detect pytest from config file", () => {
44
- createTempFile(tmpDir, "pytest.ini", "[tool:pytest]");
45
- createTempFile(tmpDir, "src/app.py", "x = 1");
46
-
47
- const result = client.detectRunner(tmpDir);
48
- expect(result).not.toBeNull();
49
- expect(result?.runner).toBe("pytest");
50
- });
51
-
52
- it("should detect runner from node_modules", () => {
53
- // Create a node_modules/vitest to simulate installed package
54
- createTempFile(tmpDir, "node_modules/vitest/package.json", "{}");
55
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
56
-
57
- const result = client.detectRunner(tmpDir);
58
- // Should detect vitest from node_modules
59
- expect(result).not.toBeNull();
60
- });
61
-
62
- it("should prefer vitest over jest when both exist", () => {
63
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
64
- createTempFile(tmpDir, "jest.config.js", "module.exports = {}");
65
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
66
-
67
- const result = client.detectRunner(tmpDir);
68
- expect(result?.runner).toBe("vitest");
69
- });
70
- });
71
-
72
- describe("findTestFile", () => {
73
- it("should find test file with .test.ts suffix", () => {
74
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
75
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
76
- createTempFile(tmpDir, "src/app.test.ts", "describe('app', () => {});");
77
-
78
- const result = client.findTestFile(
79
- path.join(tmpDir, "src/app.ts"),
80
- tmpDir,
81
- );
82
- expect(result).not.toBeNull();
83
- expect(result?.testFile).toContain("app.test.ts");
84
- expect(result?.runner).toBe("vitest");
85
- });
86
-
87
- it("should find test file with .spec.ts suffix", () => {
88
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
89
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
90
- createTempFile(tmpDir, "src/app.spec.ts", "describe('app', () => {});");
91
-
92
- const result = client.findTestFile(
93
- path.join(tmpDir, "src/app.ts"),
94
- tmpDir,
95
- );
96
- expect(result).not.toBeNull();
97
- expect(result?.testFile).toContain("app.spec.ts");
98
- });
99
-
100
- it("should find test file in __tests__ directory", () => {
101
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
102
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
103
- createTempFile(
104
- tmpDir,
105
- "src/__tests__/app.test.ts",
106
- "describe('app', () => {});",
107
- );
108
-
109
- const result = client.findTestFile(
110
- path.join(tmpDir, "src/app.ts"),
111
- tmpDir,
112
- );
113
- expect(result).not.toBeNull();
114
- expect(result?.testFile).toContain("__tests__");
115
- });
116
-
117
- it("should find test file in top-level tests/ directory", () => {
118
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
119
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
120
- createTempFile(tmpDir, "tests/app.test.ts", "describe('app', () => {});");
121
-
122
- const result = client.findTestFile(
123
- path.join(tmpDir, "src/app.ts"),
124
- tmpDir,
125
- );
126
- expect(result).not.toBeNull();
127
- expect(result?.testFile).toContain(path.join("tests", "app.test.ts"));
128
- });
129
-
130
- it("should find pytest test file with test_ prefix", () => {
131
- createTempFile(tmpDir, "pytest.ini", "[tool:pytest]");
132
- createTempFile(tmpDir, "src/app.py", "x = 1");
133
- createTempFile(tmpDir, "tests/test_app.py", "def test_app(): pass");
134
-
135
- const result = client.findTestFile(
136
- path.join(tmpDir, "src/app.py"),
137
- tmpDir,
138
- );
139
- expect(result).not.toBeNull();
140
- expect(result?.testFile).toContain("test_app.py");
141
- expect(result?.runner).toBe("pytest");
142
- });
143
-
144
- it("should return null when no test file found", () => {
145
- createTempFile(tmpDir, "vitest.config.ts", "export default {}");
146
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
147
-
148
- const result = client.findTestFile(
149
- path.join(tmpDir, "src/app.ts"),
150
- tmpDir,
151
- );
152
- expect(result).toBeNull();
153
- });
154
-
155
- it("should find test file even without config (if runner installed)", () => {
156
- // Simulate vitest installed in node_modules
157
- createTempFile(tmpDir, "node_modules/vitest/package.json", "{}");
158
- createTempFile(tmpDir, "src/app.ts", "export const app = {};");
159
- createTempFile(tmpDir, "src/app.test.ts", "describe('app', () => {});");
160
-
161
- const result = client.findTestFile(
162
- path.join(tmpDir, "src/app.ts"),
163
- tmpDir,
164
- );
165
- // Should find the test file since vitest is "installed"
166
- expect(result).not.toBeNull();
167
- });
168
- });
169
-
170
- describe("formatResult", () => {
171
- it("should format passing tests", () => {
172
- const result = {
173
- file: "/test/app.test.ts",
174
- sourceFile: "/test/app.ts",
175
- runner: "vitest",
176
- passed: 5,
177
- failed: 0,
178
- skipped: 0,
179
- failures: [],
180
- duration: 420,
181
- };
182
-
183
- const formatted = client.formatResult(result);
184
- expect(formatted).toContain("✓");
185
- expect(formatted).toContain("5/5 passed");
186
- expect(formatted).toContain("0.42s");
187
- });
188
-
189
- it("should format failing tests", () => {
190
- const result = {
191
- file: "/test/app.test.ts",
192
- sourceFile: "/test/app.ts",
193
- runner: "vitest",
194
- passed: 3,
195
- failed: 2,
196
- skipped: 0,
197
- failures: [
198
- {
199
- name: "should add",
200
- message: "expected 4, got 3",
201
- location: "app.test.ts:10",
202
- },
203
- {
204
- name: "should subtract",
205
- message: "expected 1, got 2",
206
- location: "app.test.ts:20",
207
- },
208
- ],
209
- duration: 420,
210
- };
211
-
212
- const formatted = client.formatResult(result);
213
- expect(formatted).toContain("✗");
214
- expect(formatted).toContain("2/5 failed");
215
- expect(formatted).toContain("should add");
216
- expect(formatted).toContain("should subtract");
217
- });
218
-
219
- it("should format runner errors", () => {
220
- const result = {
221
- file: "/test/app.test.ts",
222
- sourceFile: "/test/app.ts",
223
- runner: "vitest",
224
- passed: 0,
225
- failed: 0,
226
- skipped: 0,
227
- failures: [],
228
- duration: 0,
229
- error: "Test file not found",
230
- };
231
-
232
- const formatted = client.formatResult(result);
233
- expect(formatted).toContain("⚠");
234
- expect(formatted).toContain("Could not run tests");
235
- });
236
-
237
- it("should return empty string for no tests", () => {
238
- const result = {
239
- file: "/test/app.test.ts",
240
- sourceFile: "/test/app.ts",
241
- runner: "vitest",
242
- passed: 0,
243
- failed: 0,
244
- skipped: 0,
245
- failures: [],
246
- duration: 0,
247
- };
248
-
249
- const formatted = client.formatResult(result);
250
- expect(formatted).toBe("");
251
- });
252
- });
253
- });
@@ -1,27 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as os from "node:os";
3
- import * as path from "node:path";
4
- /**
5
- * Creates a temporary file within the given temp directory.
6
- * Automatically creates parent directories if they don't exist.
7
- */
8
- export function createTempFile(tmpDir, name, content) {
9
- const filePath = path.join(tmpDir, name);
10
- const dir = path.dirname(filePath);
11
- fs.mkdirSync(dir, { recursive: true });
12
- fs.writeFileSync(filePath, content);
13
- return filePath;
14
- }
15
- /**
16
- * Creates a temporary directory for testing.
17
- * Returns the path and a cleanup function.
18
- */
19
- export function setupTestEnvironment(prefix) {
20
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
21
- const cleanup = () => {
22
- if (tmpDir) {
23
- fs.rmSync(tmpDir, { recursive: true, force: true });
24
- }
25
- };
26
- return { tmpDir, cleanup };
27
- }
@@ -1,36 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as os from "node:os";
3
- import * as path from "node:path";
4
-
5
- /**
6
- * Creates a temporary file within the given temp directory.
7
- * Automatically creates parent directories if they don't exist.
8
- */
9
- export function createTempFile(
10
- tmpDir: string,
11
- name: string,
12
- content: string,
13
- ): string {
14
- const filePath = path.join(tmpDir, name);
15
- const dir = path.dirname(filePath);
16
- fs.mkdirSync(dir, { recursive: true });
17
- fs.writeFileSync(filePath, content);
18
- return filePath;
19
- }
20
-
21
- /**
22
- * Creates a temporary directory for testing.
23
- * Returns the path and a cleanup function.
24
- */
25
- export function setupTestEnvironment(prefix: string): {
26
- tmpDir: string;
27
- cleanup: () => void;
28
- } {
29
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
30
- const cleanup = () => {
31
- if (tmpDir) {
32
- fs.rmSync(tmpDir, { recursive: true, force: true });
33
- }
34
- };
35
- return { tmpDir, cleanup };
36
- }