mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-14 22:05:22 +03:00
fix(web-test): резолвить корень сьюта подъёмом вверх, а не от переданного пути
Конфиг и хуки резолвились строго от каталога первого позиционного пути, поэтому запуск подкаталога сьюта был невозможен: `test tests/app/00-smoke/` падал с «No URL provided and no webtest.config.mjs found» — хотя спека прямо обещает запуск подкаталога («Фильтр по пути с CLI»). Опаснее отказа по URL были два молчаливых следствия: при `--url=` прогон подкаталога терял `_hooks.mjs` и ехал по неподготовленному стенду без единого предупреждения, а `_allure/` не находился. Плюс `file:` в отчёте считался от переданного пути, из-за чего один и тот же тест получал разный ID в зависимости от способа запуска и рвал историю Allure/JUnit. Введён корень сьюта: подъём от каталога пути до первого `webtest.config.mjs` ИЛИ `_hooks.mjs` (конфиг необязателен — сьют только с хуками иначе снова терял бы подготовку), с ограничением подъёма каталогом `.git`/`.v8-project.json`, а при их отсутствии — cwd. Граница ничего не выбирает, только останавливает, так что ложная граница даёт «корень не найден», а не чужой корень. От найденного корня берутся все пять ролей: конфиг, хуки, каталог отчёта, пути в отчёте, `_allure/`. Попутно: пути из разных сьютов в одном прогоне теперь отвергаются (раньше молча выигрывал первый путь, и сьют B ехал по подготовке сьюта A); найденный корень печатается в шапке; отсутствие корня — предупреждение в stderr; диагностика говорит про корень сьюта, а не только про URL. Проверено: 12/12 офлайн-кейсов резолвера; полный регресс 29/29 до и после — `file`/`name`/`status` идентичны; `_suite-root/nested/` (сценарий, который падал) проходит с подхваченными конфигом и хуками; `_hang/` 6/6. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
9c7010a49e
commit
90d8263a05
@@ -10,6 +10,8 @@ node $RUN test <dir|file>... [flags]
|
||||
|
||||
Positional args are test paths (files and/or dirs, multiple allowed). URL is NOT positional — it comes from `webtest.config.mjs`; override with `--url=<url>`.
|
||||
|
||||
`webtest.config.mjs` and `_hooks.mjs` are looked up by walking UP from the given path to the nearest directory holding either of them — the suite root. So `test tests/myapp/sales/` and `test tests/myapp/sales/01-order.test.mjs` work without `--url=`, taking the config and the hooks of `tests/myapp/`. The climb stops at a directory with `.git` / `.v8-project.json`, otherwise at the working directory. Paths from different suites in one run are refused — their config and hooks would be ambiguous.
|
||||
|
||||
Tests live next to the project they cover (not inside the skill). Convention: `tests/` at the project root, with `_hooks.mjs` and `webtest.config.mjs` at the suite root. Tests are ES modules with `*.test.mjs` suffix.
|
||||
|
||||
## When to choose `test` over `exec`
|
||||
@@ -69,7 +71,7 @@ tests/<app-name>/
|
||||
01-end-to-end.test.mjs # multi-user
|
||||
```
|
||||
|
||||
Per-folder `_hooks.mjs` / `webtest.config.mjs` inside the application subfolder are NOT supported — only the application-root copies are loaded.
|
||||
Per-folder `_hooks.mjs` / `webtest.config.mjs` inside the application subfolder are NOT supported — only the application-root copies are loaded, whichever subfolder you point the runner at. (A nested folder that DOES carry its own `webtest.config.mjs` is not a sub-suite — it becomes a separate suite root, and its parent's hooks no longer apply.)
|
||||
|
||||
## Test file anatomy
|
||||
|
||||
|
||||
Reference in New Issue
Block a user