pi-lens 3.6.2 → 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.
- package/CHANGELOG.md +10 -2
- package/package.json +4 -4
- package/tsconfig.json +1 -1
- package/clients/__tests__/file-time.test.js +0 -216
- package/clients/__tests__/file-time.test.ts +0 -276
- package/clients/__tests__/format-service.test.js +0 -245
- package/clients/__tests__/format-service.test.ts +0 -339
- package/clients/__tests__/formatters.test.js +0 -271
- package/clients/__tests__/formatters.test.ts +0 -401
- package/clients/agent-behavior-client.js +0 -110
- package/clients/agent-behavior-client.test.js +0 -94
- package/clients/agent-behavior-client.test.ts +0 -116
- package/clients/amain-types.js +0 -164
- package/clients/architect-client.js +0 -291
- package/clients/ast-grep-client.js +0 -253
- package/clients/ast-grep-parser.js +0 -84
- package/clients/ast-grep-rule-manager.js +0 -89
- package/clients/ast-grep-types.js +0 -9
- package/clients/auto-loop.js +0 -131
- package/clients/biome-client.js +0 -420
- package/clients/biome-client.test.js +0 -144
- package/clients/biome-client.test.ts +0 -163
- package/clients/cache/rule-cache.js +0 -72
- package/clients/cache-manager.js +0 -245
- package/clients/cache-manager.test.js +0 -197
- package/clients/cache-manager.test.ts +0 -299
- package/clients/complexity-client.js +0 -675
- package/clients/complexity-client.test.js +0 -234
- package/clients/complexity-client.test.ts +0 -255
- package/clients/config-validator.js +0 -465
- package/clients/dependency-checker.js +0 -325
- package/clients/dependency-checker.test.js +0 -60
- package/clients/dependency-checker.test.ts +0 -71
- package/clients/dispatch/__tests__/autofix-integration.test.js +0 -245
- package/clients/dispatch/__tests__/autofix-integration.test.ts +0 -300
- package/clients/dispatch/__tests__/runner-registration.test.js +0 -234
- package/clients/dispatch/__tests__/runner-registration.test.ts +0 -286
- package/clients/dispatch/debug.log +0 -1
- package/clients/dispatch/dispatcher.edge.test.js +0 -82
- package/clients/dispatch/dispatcher.edge.test.ts +0 -100
- package/clients/dispatch/dispatcher.format.test.js +0 -46
- package/clients/dispatch/dispatcher.format.test.ts +0 -58
- package/clients/dispatch/dispatcher.inline.test.js +0 -74
- package/clients/dispatch/dispatcher.inline.test.ts +0 -93
- package/clients/dispatch/dispatcher.js +0 -381
- package/clients/dispatch/dispatcher.test.js +0 -116
- package/clients/dispatch/dispatcher.test.ts +0 -149
- package/clients/dispatch/integration.js +0 -108
- package/clients/dispatch/plan.js +0 -183
- package/clients/dispatch/runners/architect.js +0 -83
- package/clients/dispatch/runners/architect.test.js +0 -138
- package/clients/dispatch/runners/architect.test.ts +0 -162
- package/clients/dispatch/runners/ast-grep-napi.js +0 -405
- package/clients/dispatch/runners/ast-grep-napi.test.js +0 -107
- package/clients/dispatch/runners/ast-grep-napi.test.ts +0 -129
- package/clients/dispatch/runners/ast-grep.js +0 -157
- package/clients/dispatch/runners/biome.js +0 -55
- package/clients/dispatch/runners/config-validation.js +0 -67
- package/clients/dispatch/runners/go-vet.js +0 -48
- package/clients/dispatch/runners/index.js +0 -47
- package/clients/dispatch/runners/lsp.js +0 -102
- package/clients/dispatch/runners/oxlint.js +0 -67
- package/clients/dispatch/runners/oxlint.test.js +0 -230
- package/clients/dispatch/runners/oxlint.test.ts +0 -303
- package/clients/dispatch/runners/pyright.js +0 -100
- package/clients/dispatch/runners/pyright.test.js +0 -98
- package/clients/dispatch/runners/pyright.test.ts +0 -121
- package/clients/dispatch/runners/python-slop.js +0 -97
- package/clients/dispatch/runners/python-slop.test.js +0 -203
- package/clients/dispatch/runners/python-slop.test.ts +0 -298
- package/clients/dispatch/runners/ruff.js +0 -48
- package/clients/dispatch/runners/rust-clippy.js +0 -102
- package/clients/dispatch/runners/scan_codebase.test.js +0 -89
- package/clients/dispatch/runners/scan_codebase.test.ts +0 -105
- package/clients/dispatch/runners/shellcheck.js +0 -147
- package/clients/dispatch/runners/shellcheck.test.js +0 -98
- package/clients/dispatch/runners/shellcheck.test.ts +0 -129
- package/clients/dispatch/runners/similarity.js +0 -230
- package/clients/dispatch/runners/spellcheck.js +0 -106
- package/clients/dispatch/runners/spellcheck.test.js +0 -158
- package/clients/dispatch/runners/spellcheck.test.ts +0 -214
- package/clients/dispatch/runners/tree-sitter.js +0 -246
- package/clients/dispatch/runners/ts-lsp.js +0 -125
- package/clients/dispatch/runners/ts-slop.js +0 -113
- package/clients/dispatch/runners/type-safety.js +0 -142
- package/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -134
- package/clients/dispatch/runners/utils/runner-helpers.js +0 -115
- package/clients/dispatch/runners/utils.js +0 -51
- package/clients/dispatch/runners/yaml-rule-parser.js +0 -360
- package/clients/dispatch/types.js +0 -16
- package/clients/dispatch/utils/format-utils.js +0 -44
- package/clients/dogfood.test.js +0 -201
- package/clients/dogfood.test.ts +0 -269
- package/clients/file-kinds.js +0 -177
- package/clients/file-kinds.test.js +0 -169
- package/clients/file-kinds.test.ts +0 -210
- package/clients/file-time.js +0 -152
- package/clients/file-utils.js +0 -40
- package/clients/fix-scanners.js +0 -204
- package/clients/format-service.js +0 -184
- package/clients/formatters.js +0 -488
- package/clients/go-client.js +0 -203
- package/clients/go-client.test.js +0 -127
- package/clients/go-client.test.ts +0 -143
- package/clients/installer/index.js +0 -403
- package/clients/interviewer-templates.js +0 -75
- package/clients/interviewer.js +0 -173
- package/clients/jscpd-client.js +0 -196
- package/clients/jscpd-client.test.js +0 -127
- package/clients/jscpd-client.test.ts +0 -145
- package/clients/knip-client.js +0 -239
- package/clients/knip-client.test.js +0 -112
- package/clients/knip-client.test.ts +0 -128
- package/clients/latency-logger.js +0 -40
- package/clients/lsp/__tests__/client.test.js +0 -310
- package/clients/lsp/__tests__/client.test.ts +0 -412
- package/clients/lsp/__tests__/config.test.js +0 -167
- package/clients/lsp/__tests__/config.test.ts +0 -217
- package/clients/lsp/__tests__/error-recovery.test.js +0 -213
- package/clients/lsp/__tests__/error-recovery.test.ts +0 -279
- package/clients/lsp/__tests__/integration.test.js +0 -127
- package/clients/lsp/__tests__/integration.test.ts +0 -160
- package/clients/lsp/__tests__/launch.test.js +0 -313
- package/clients/lsp/__tests__/launch.test.ts +0 -394
- package/clients/lsp/__tests__/server.test.js +0 -259
- package/clients/lsp/__tests__/server.test.ts +0 -332
- package/clients/lsp/__tests__/service.test.js +0 -438
- package/clients/lsp/__tests__/service.test.ts +0 -530
- package/clients/lsp/client.js +0 -350
- package/clients/lsp/config.js +0 -112
- package/clients/lsp/index.js +0 -318
- package/clients/lsp/installer/index.js +0 -391
- package/clients/lsp/interactive-install.js +0 -221
- package/clients/lsp/language.js +0 -170
- package/clients/lsp/launch.js +0 -329
- package/clients/lsp/lsp/launch.js +0 -116
- package/clients/lsp/lsp/server.js +0 -532
- package/clients/lsp/lsp-index.js +0 -10
- package/clients/lsp/path-utils.js +0 -5
- package/clients/lsp/server.js +0 -725
- package/clients/lsp/test-py-spawn/requirements.txt +0 -1
- package/clients/lsp/test-py-spawn/test.py +0 -3
- package/clients/lsp/test-py-svc/requirements.txt +0 -1
- package/clients/lsp/test-py-svc/test.py +0 -3
- package/clients/lsp/test-python-project/requirements.txt +0 -1
- package/clients/lsp/test-python-project/test.py +0 -5
- package/clients/metrics-client.js +0 -107
- package/clients/metrics-client.test.js +0 -128
- package/clients/metrics-client.test.ts +0 -163
- package/clients/metrics-history.js +0 -367
- package/clients/path-utils.js +0 -142
- package/clients/pipeline.js +0 -272
- package/clients/production-readiness.js +0 -522
- package/clients/project-index.js +0 -255
- package/clients/project-metadata.js +0 -531
- package/clients/ruff-client.js +0 -325
- package/clients/ruff-client.test.js +0 -132
- package/clients/ruff-client.test.ts +0 -153
- package/clients/rules-scanner.js +0 -97
- package/clients/runner-tracker.js +0 -152
- package/clients/rust-client.js +0 -205
- package/clients/rust-client.test.js +0 -108
- package/clients/rust-client.test.ts +0 -130
- package/clients/safe-spawn-async.js +0 -163
- package/clients/safe-spawn.js +0 -241
- package/clients/sanitize.js +0 -291
- package/clients/sanitize.test.js +0 -177
- package/clients/sanitize.test.ts +0 -223
- package/clients/scan-architectural-debt.js +0 -167
- package/clients/scan-utils.js +0 -83
- package/clients/secrets-scanner.js +0 -119
- package/clients/secrets-scanner.test.js +0 -100
- package/clients/secrets-scanner.test.ts +0 -113
- package/clients/sg-runner.js +0 -292
- package/clients/state-matrix.js +0 -160
- package/clients/subprocess-client.js +0 -65
- package/clients/symbol-types.js +0 -5
- package/clients/test-runner-client.js +0 -523
- package/clients/test-runner-client.test.js +0 -192
- package/clients/test-runner-client.test.ts +0 -253
- package/clients/test-utils.js +0 -27
- package/clients/test-utils.ts +0 -36
- package/clients/todo-scanner.js +0 -200
- package/clients/todo-scanner.test.js +0 -301
- package/clients/todo-scanner.test.ts +0 -352
- package/clients/tool-availability.js +0 -207
- package/clients/tree-sitter-client.js +0 -601
- package/clients/tree-sitter-query-loader.js +0 -355
- package/clients/tree-sitter-symbol-extractor.js +0 -289
- package/clients/ts-service.js +0 -129
- package/clients/type-coverage-client.js +0 -127
- package/clients/type-coverage-client.test.js +0 -105
- package/clients/type-coverage-client.test.ts +0 -125
- package/clients/type-safety-client.js +0 -138
- package/clients/types.js +0 -11
- package/clients/typescript-client.codefix.test.js +0 -157
- package/clients/typescript-client.codefix.test.ts +0 -186
- package/clients/typescript-client.js +0 -509
- package/clients/typescript-client.test.js +0 -105
- package/clients/typescript-client.test.ts +0 -126
- package/commands/booboo.js +0 -1007
- package/commands/fix-from-booboo.js +0 -398
- package/commands/fix-simplified.js +0 -618
- package/commands/rate.js +0 -281
- package/commands/rate.test.js +0 -119
- package/commands/rate.test.ts +0 -131
- 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
|
-
});
|
package/clients/test-utils.js
DELETED
|
@@ -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
|
-
}
|
package/clients/test-utils.ts
DELETED
|
@@ -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
|
-
}
|