@7n/test 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +4 -1
- package/src/coverage-per-file.mjs +13 -5
- package/src/fix-tests.mjs +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.0] - 2026-06-27
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `vitest` і `@vitest/coverage-v8` тепер є залежностями `@7n/test` — цільовий проєкт більше не потребує їх у `devDependencies`. Vitest викликається з node_modules самого пакету через `process.execPath`. Додано бінарний аліас `7n-test` поряд з `test` — усуває конфлікт з shell built-in при `npx @7n/test`.
|
|
8
|
+
|
|
3
9
|
## [0.5.0] - 2026-06-27
|
|
4
10
|
|
|
5
11
|
### Changed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@7n/test",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "CLI-утиліта @7n/test",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"7n",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"url": "git+https://github.com/nitra/7n-test.git"
|
|
19
19
|
},
|
|
20
20
|
"bin": {
|
|
21
|
+
"7n-test": "bin/7n-test.js",
|
|
21
22
|
"test": "bin/7n-test.js"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
@@ -40,6 +41,8 @@
|
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@earendil-works/pi-coding-agent": "^0.80.2",
|
|
44
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
45
|
+
"vitest": "^4.1.9",
|
|
43
46
|
"zod": "^3.23.0"
|
|
44
47
|
},
|
|
45
48
|
"engines": {
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-file coverage via vitest + lcov.
|
|
3
|
-
* Runs
|
|
4
|
-
*
|
|
3
|
+
* Runs vitest (bundled with @7n/test) in a single pass and returns
|
|
4
|
+
* both per-file coverage data and failing tests.
|
|
5
|
+
* Target projects do NOT need vitest or @vitest/coverage-v8 installed.
|
|
5
6
|
*/
|
|
6
7
|
import { spawnSync } from 'node:child_process'
|
|
7
8
|
import { existsSync, readFileSync } from 'node:fs'
|
|
8
9
|
import { mkdtemp, rm } from 'node:fs/promises'
|
|
9
10
|
import { tmpdir } from 'node:os'
|
|
10
|
-
import {
|
|
11
|
+
import { createRequire } from 'node:module'
|
|
12
|
+
import { join, relative, dirname } from 'node:path'
|
|
11
13
|
import { env } from 'node:process'
|
|
12
14
|
|
|
15
|
+
const _require = createRequire(import.meta.url)
|
|
16
|
+
const VITEST_BIN = join(
|
|
17
|
+
dirname(_require.resolve('vitest/package.json')),
|
|
18
|
+
'vitest.mjs'
|
|
19
|
+
)
|
|
20
|
+
|
|
13
21
|
const TEST_FILE_RE = /\.(test|spec)\.[^.]+$|[/\\]tests?[/\\]/
|
|
14
22
|
const MAX_ERRORS_PER_FILE = 5
|
|
15
23
|
const MAX_ERROR_LINES = 10
|
|
@@ -85,9 +93,9 @@ export async function measureCoveragePerFile(dir) {
|
|
|
85
93
|
|
|
86
94
|
try {
|
|
87
95
|
spawnSync(
|
|
88
|
-
|
|
96
|
+
process.execPath,
|
|
89
97
|
[
|
|
90
|
-
|
|
98
|
+
VITEST_BIN,
|
|
91
99
|
'run',
|
|
92
100
|
'--passWithNoTests',
|
|
93
101
|
'--coverage',
|
package/src/fix-tests.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* fix-tests: виявляє падаючі unit-тести і викликає pi-агента для їх виправлення.
|
|
3
3
|
*
|
|
4
4
|
* Порядок роботи:
|
|
5
|
-
* 1. getFailingTests(dir) — запускає
|
|
5
|
+
* 1. getFailingTests(dir) — запускає vitest run --reporter=json і повертає
|
|
6
6
|
* список падаючих файлів з повідомленнями про помилки.
|
|
7
7
|
* 2. fixFailingTests(dir, opts) — якщо є падіння, будує prompt і викликає pi CLI
|
|
8
8
|
* в агентному режимі; перевіряє результат повторним getFailingTests.
|
|
@@ -10,10 +10,17 @@
|
|
|
10
10
|
import { spawnSync } from 'node:child_process'
|
|
11
11
|
import { existsSync, readFileSync } from 'node:fs'
|
|
12
12
|
import { mkdtemp, rm } from 'node:fs/promises'
|
|
13
|
+
import { createRequire } from 'node:module'
|
|
13
14
|
import { tmpdir } from 'node:os'
|
|
14
|
-
import { join, relative } from 'node:path'
|
|
15
|
+
import { join, relative, dirname } from 'node:path'
|
|
15
16
|
import { env } from 'node:process'
|
|
16
17
|
|
|
18
|
+
const _require = createRequire(import.meta.url)
|
|
19
|
+
const VITEST_BIN = join(
|
|
20
|
+
dirname(_require.resolve('vitest/package.json')),
|
|
21
|
+
'vitest.mjs'
|
|
22
|
+
)
|
|
23
|
+
|
|
17
24
|
const MODEL = env.N_CURSOR_FIX_TESTS_MODEL ?? env.N_CLOUD_MAX_MODEL ?? ''
|
|
18
25
|
const MAX_ERRORS_PER_FILE = 5
|
|
19
26
|
const MAX_ERROR_LINES = 10
|
|
@@ -28,7 +35,7 @@ export async function getFailingTests(dir) {
|
|
|
28
35
|
const outputFile = join(tmpDir, 'results.json')
|
|
29
36
|
|
|
30
37
|
try {
|
|
31
|
-
spawnSync(
|
|
38
|
+
spawnSync(process.execPath, [VITEST_BIN, 'run', '--reporter=json', `--outputFile=${outputFile}`, '--passWithNoTests'], {
|
|
32
39
|
cwd: dir,
|
|
33
40
|
stdio: 'inherit',
|
|
34
41
|
env
|