Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(core): a tests/ folder inside a JS or TS src tree is not a test directory (#4322)

Raghav Chamadiya86ae7ae14646
diff --git a/docs/start/CI.md b/docs/start/CI.md
index 4d1cd3f67..7fd671e83 100644
--- a/docs/start/CI.md
+++ b/docs/start/CI.md
@@ -278,7 +278,7 @@ a per-test coverage map (`repowise coverage add`) makes it more precise.
- It also runs everything for: a missing or unreadable index; a per-test map at its row cap; a deleted file no known test used.
- An index built at an older commit than the change's base is used as is. Files changed in between whose imports or module-name strings moved (any change beyond whitespace, outside Python and JavaScript/TypeScript) add the tests reaching them. It runs everything instead when that commit is not in the clone, or more than 1,000 files changed in between, or one of them is a lockfile, manifest, build or test config or `.repowise/config.yaml`. CI config and test data changed in between no longer force a full run: neither is imported.
- Only `docs/` and root README-like files (README, CHANGELOG, LICENSE, CONTRIBUTING) are skipped, and only when no code names them (a test that reads `README.md` names it, and then runs); an empty line means only those changed.
-- Tests the graph cannot see into run with every subset, and the reasons say how many and why: a test not indexed or importing nothing it resolves; a Python, JavaScript or TypeScript test that lists and reads files under a source directory (the working directory, a module's location, or its own location climbed out of the test directory; never its fixtures, sibling data or a temporary directory); one that runs the project's own command, `python -m` module, code importing the project, or package `bin` in a child process; a Java or Kotlin `@SpringBootTest`, which loads the whole application context (a slice such as `@WebMvcTest` is selected through its imports). A test that inherits `@SpringBootTest` from a base class or carries it through a custom meta-annotation is not detected and is selected through its imports only. The indexer finds them once from each test's source and stores the reason, so selection reads it without opening test files. An index built before this check runs everything until `repowise update` checks its tests. A Python module named like a test but outside every test directory is not a test when the nearest pytest config's `testpaths` or `python_files` leaves it out, as a bare `pytest` does: it is selected through like any other code. The rule follows a bare `pytest` run, so a test that CI only names explicitly on the command line outside `testpaths` is not seen as one: list it in `tests.always_run`.
+- Tests the graph cannot see into run with every subset, and the reasons say how many and why: a test not indexed or importing nothing it resolves; a Python, JavaScript or TypeScript test that lists and reads files under a source directory (the working directory, a module's location, or its own location climbed out of the test directory; never its fixtures, sibling data or a temporary directory); one that runs the project's own command, `python -m` module, code importing the project, or package `bin` in a child process; a Java or Kotlin `@SpringBootTest`, which loads the whole application context (a slice such as `@WebMvcTest` is selected through its imports). A test that inherits `@SpringBootTest` from a base class or carries it through a custom meta-annotation is not detected and is selected through its imports only. The indexer finds them once from each test's source and stores the reason, so selection reads it without opening test files. An index built before this check runs everything until `repowise update` checks its tests. A Python module named like a test but outside every test directory is not a test when the nearest pytest config's `testpaths` or `python_files` leaves it out, as a bare `pytest` does: it is selected through like any other code. The rule follows a bare `pytest` run, so a test that CI only names explicitly on the command line outside `testpaths` is not seen as one: list it in `tests.always_run`. Inside a JavaScript or TypeScript `src` tree a `tests/` folder is not a test directory, since it often holds a product feature: a file there is a test when its name says so (`.test.`, `.spec.`) or a test directory such as `__tests__/` holds it.
- A changed `conftest.py`, test package `__init__.py` or imported test helper selects the tests under or importing it, not everything.
- A change that reaches a `conftest.py` only through its imports selects the tests that ask for a fixture using that change (directly, through other fixtures, `usefixtures` or `getfixturevalue`), plus one test under the conftest as an import check.
- Every test under the conftest still runs when an autouse fixture, a `pytest_*` hook or module-level code uses the change, or when the conftest imports it only for side effects.
diff --git a/packages/core/src/repowise/core/analysis/actions/build.py b/packages/core/src/repowise/core/analysis/actions/build.py
index a59ddd11f..937760f6a 100644
--- a/packages/core/src/repowise/core/analysis/actions/build.py
+++ b/packages/core/src/repowise/core/analysis/actions/build.py
@@ -73,6 +73,7 @@ from repowise.core.analysis.health.queue.eligibility import perf_confident_verdi
from repowise.core.analysis.health.rows import field
from repowise.core.analysis.health.scoring import HISTORY_CATEGORY, biomarker_category
from repowise.core.author_identity import author_identity_key
+from repowise.core.test_paths import is_test_related_path
from .context import WEEK, build_context
from .facts import (
@@ -121,17 +122,12 @@ def _open(row: Any) -> bool:
return (field(row, "status") or "open") == "open"
-def _is_test(path: str, files: Mapping[str, FileFacts]) -> bool:
- f = files.get(path)
- return f is not None and f.is_test
-
-
-def _test_path(path: str | None) -> bool:
- lowered = (path or "").lower()
- return any(
- seg in lowered
- for seg in ("/tests/", "/test/", "__tests__", "/fixtures/", ".test.", ".spec.", "_test.")
- ) or lowered.startswith(("tests/", "test/"))
+def _is_test(path: str | None, files: Mapping[str, FileFacts]) -> bool:
+ """The stored test flag, or the shared classifier for a file the index lacks."""
+ f = files.get(path or "")
+ if f is not None:
+ return f.is_test
+ return bool(path) and is_test_related_path(path)
# --- files --------------------------------------------------------------------
@@ -453,7 +449,6 @@ def build_secrets(rows: Rows, files: Mapping[str, FileFacts]) -> dict[str, Any]:
and field(r, "severity") == "high"
and field(r, "kind") in kinds
and not _is_test(field(r, "file_path"), files)
- and not _test_path(field(r, "file_path"))
)
}
@@ -493,7 +488,6 @@ def build_dead(rows: Rows, files: Mapping[str, FileFacts]) -> dict[str, Any]:
and field(r, "safe_to_delete")
and is_served("dead_code", field(r, "kind"), field(r, "file_path"), skipped)
and not _is_test(field(r, "file_path"), files)
- and not _test_path(field(r, "file_path"))
)
}
diff --git a/packages/core/src/repowise/core/analysis/health/asserts/oracle_reach.py b/packages/core/src/repowise/core/analysis/health/asserts/oracle_reach.py
index 428d4477c..9647f4817 100644
--- a/packages/core/src/repowise/core/analysis/health/asserts/oracle_reach.py
+++ b/packages/core/src/repowise/core/analysis/health/asserts/oracle_reach.py
@@ -91,7 +91,6 @@ from typing import TYPE_CHECKING, Any
from ....test_paths import is_test_related_path
from ...execution_graph import ExecutionGraphIndex, file_of_symbol, reachable_to_sink
-from ..coverage import is_test_file
from .predicate import checks_something
if TYPE_CHECKING:
@@ -195,7 +194,7 @@ def collect_cross_file_oracles(
oracle_name: dict[str, str] = {}
for pf, fcx in walked_list:
path = pf.file_info.path
- if not is_test_related_path(path, pf.file_info.language):
+ if not _is_test_material(pf.file_info):
continue
for fn in fcx.functions:
if not checks_something(fn):
@@ -324,6 +323,17 @@ def _oracles_by_file_and_name(
def _candidates(pf: Any, fcx: FileComplexity) -> list[Any]:
"""Test cases in a test file that check nothing themselves."""
- if not is_test_file(pf.file_info.path):
+ if not _is_test_material(pf.file_info):
return []
return [fn for fn in fcx.functions if fn.is_test_case and not checks_something(fn)]
+
+
+def _is_test_material(file_info: Any) -> bool:
+ """The ``is_test`` flag ingestion stored, which saw pytest's config.
+
+ The path rules answer only for a caller that built no flag.
+ """
+ stored = getattr(file_info, "is_test", None)
+ if stored is not None:
+ return bool(stored)
+ return is_test_related_path(file_info.path, getattr(file_info, "language", None))
diff --git a/packages/core/src/repowise/core/analysis/health/coverage/README.md b/packages/core/src/repowise/core/analysis/health/coverage/README.md
index 47617f578..7166f5a97 100644
--- a/packages/core/src/repowise/core/analysis/health/coverage/README.md
+++ b/packages/core/src/repowise/core/analysis/health/coverage/README.md
@@ -55,7 +55,7 @@ normalized once (keyed by repo-relative POSIX path) and fed to
total_coverable_lines)` pin a file down; an entry that anchors none is
skipped (absent ≠ zero).
- `detect_format(text)` — returns the sniffed format or ``None``.
-- `is_test_file(path, source=None)` — path + optional content heuristic.
+- `is_test_file(path, source=None, *, roots=None)` — path + optional content heuristic; pass pytest `roots` so a module pytest does not collect is not a test. Callers holding the stored `is_test` flag use that instead.
- `paired_test_file(path, all_paths)` — find the conventional test
partner for a source path.
diff --git a/packages/core/src/repowise/core/analysis/health/coverage/detector.py b/packages/core/src/repowise/core/analysis/health/coverage/detector.py
index 86ed87490..15f88b93f 100644
--- a/packages/core/src/repowise/core/analysis/health/coverage/detector.py
+++ b/packages/core/src/repowise/core/analysis/health/coverage/detector.py
@@ -29,6 +29,7 @@ from __future__ import annotations
import re
from collections.abc import Callable
+from typing import TYPE_CHECKING
from ....test_paths import is_test_related_path
from .clover import parse_clover
@@ -39,6 +40,9 @@ from .lcov import parse_lcov
from .model import CoverageReport
from .repowise_json import parse_repowise_json
+if TYPE_CHECKING:
+ from ....pytest_roots import PytestRoots
+
# Test framework import patterns — used when the path heuristic is
# inconclusive. Detected via cheap substring scan (no tree-sitter pass).
_FRAMEWORK_IMPORTS = (
@@ -146,15 +150,19 @@ def parse(text: str, *, format: str | None = None) -> CoverageReport:
return parser(text.lstrip(_BOM))
-def is_test_file(rel_path: str, source: str | None = None) -> bool:
+def is_test_file(
+ rel_path: str, source: str | None = None, *, roots: PytestRoots | None = None
+) -> bool:
"""Does *rel_path* look like a test file?
The path rules live in :mod:`repowise.core.test_paths`, the one home for
them (#1103). What this adds is the *source* branch: given a file body, a
test-framework import marks a test whose path follows no convention at all,
- which no amount of path matching can tell you.
+ which no amount of path matching can tell you. Pass *roots* so pytest's
+ config can keep a test-named production module (``core/test_x.py``) out.
+ Callers holding a stored ``is_test`` flag should read that instead.
"""
- if is_test_related_path(rel_path):
+ if is_test_related_path(rel_path, roots=roots):
return True
if source:
head = source[:4096]
diff --git a/packages/core/src/repowise/core/analysis/health/engine.py b/packages/core/src/repowise/core/analysis/health/engine.py
index ab30ea236..b86b67540 100644
--- a/packages/core/src/repowise/core/analysis/health/engine.py
+++ b/packages/core/src/repowise/core/analysis/health/engine.py
@@ -98,6 +98,11 @@ log = structlog.get_logger(__name__)
# Not a licence to move a calibrated scoring weight — those are frozen
# independently of this stamp.
#
+# v42: a JavaScript-family file under a ``tests/`` folder inside a ``src`` tree
+# is production unless its name or a test directory says otherwise, and the
+# cross-file assertion pass reads the stored test flag, which moves scope and
+# findings for those files.
+#
# v41 (also): a loop that grows only by reading tables that do not grow with
# the repository is bounded (``perf.table_scale``), so its causes leave the queue.
# v41 (also): ``docs`` / ``docs_src`` count as a docs root only at the
@@ -398,7 +403,7 @@ log = structlog.get_logger(__name__)
# forms. Files that were counted untested and are not become tested, which
# moves untested-hotspot findings and the scores that carry them, on every
# language with a prefix or spec convention rather than Ruby alone.
-HEALTH_ANALYZER_VERSION = 41
+HEALTH_ANALYZER_VERSION = 42
def _log_duplication_diagnostics(report: DuplicationReport) -> None:
diff --git a/packages/core/src/repowise/core/analysis/knowledge_graph.py b/packages/core/src/repowise/core/analysis/knowledge_graph.py
index 259da1c3f..571b4ccdb 100644
--- a/packages/core/src/repowise/core/analysis/knowledge_graph.py
+++ b/packages/core/src/repowise/core/analysis/knowledge_graph.py
@@ -220,7 +220,9 @@ def _slugify(text: str) -> str:
# ``test`` tag on file nodes without moving a node or edge count.
# "6": a test-named Python module that pytest's config does not collect is no
# longer a test, moving its ``test`` tag.
-KG_BUILDER_VERSION = "6"
+# "7": a JavaScript-family file under a ``tests/`` folder inside a ``src`` tree
+# is not a test by that folder alone, moving its ``test`` tag.
+KG_BUILDER_VERSION = "7"
# An unmapped type is dropped from the export entirely (see the
# `if not kg_type: continue` below), which is silent. Six real types used to be
diff --git a/packages/core/src/repowise/core/test_paths.py b/packages/core/src/repowise/core/test_paths.py
index f67f84b0f..446c304d1 100644
--- a/packages/core/src/repowise/core/test_paths.py
+++ b/packages/core/src/repowise/core/test_paths.py
@@ -119,6 +119,19 @@ _JVM_SOURCE_ROOTS: frozenset[str] = frozenset({"java", "kotlin", "groovy", "scal
# GitHub's repository-metadata directory; see ``_classify``.
_REPO_METADATA_DIR = ".github"
+# Inside a JavaScript-family ``src`` tree a ``tests/`` folder is as often a
+# product feature (a Tests page, the components behind it) as a suite, and
+# Jest, Vitest and Playwright collect there by file name, never by folder. So
+# below ``src`` it makes no test tree for these files: a ``.test.``/``.spec.``
+# name, ``__tests__/`` and the scaffolding directories still do. A ``tests/``
+# outside ``src`` keeps counting, because Mocha, AVA and ``node --test`` collect
+# a whole ``test(s)/`` folder by default. Ceiling: an AVA or Mocha run pointed at
+# a ``src/**/tests/`` folder of plainly named files reads as production; reading
+# the runner config's globs would settle that case.
+_JS_FAMILY_TAGS: tuple[str, ...] = ("javascript", "typescript", "vue", "svelte", "astro")
+_SOURCE_TREE = "src"
+_FEATURE_NAMED_TESTS_DIR = "tests"
+
# The separators a directory segment splits into words on.
_SEGMENT_WORD_SEPARATORS = re.compile(r"[-_.]+")
@@ -228,6 +241,7 @@ class _Conventions:
unambiguous_dir_suffixes: tuple[str, ...]
lang_dir_tokens: dict[str, frozenset[str]]
manifest_names: frozenset[str]
+ js_family_exts: frozenset[str]
@cache
@@ -271,6 +285,7 @@ def _conventions() -> _Conventions:
),
lang_dir_tokens=REGISTRY.test_dir_tokens_by_language(),
manifest_names=REGISTRY.package_manifest_filenames(),
+ js_family_exts=REGISTRY.extensions_for(_JS_FAMILY_TAGS),
)
@@ -384,6 +399,26 @@ def _is_test_dir(
)
+def _tree_segments(
+ segments: list[str], original: list[str], filename: str
+) -> tuple[list[str], list[str]]:
+ """*segments* with the ``src/**/tests/`` folders a JS-family file ignores blanked.
+
+ Blanked rather than dropped, so the layout rules keep their positions.
+ """
+ if (
+ PurePosixPath(filename.lower()).suffix not in _conventions().js_family_exts
+ or _SOURCE_TREE not in segments
+ ):
+ return segments, original
+ src = segments.index(_SOURCE_TREE)
+ keep = [i < src or seg != _FEATURE_NAMED_TESTS_DIR for i, seg in enumerate(segments)]
+ return (
+ [seg if k else "" for seg, k in zip(segments, keep, strict=True)],
+ [seg if k else "" for seg, k in zip(original, keep, strict=True)],
+ )
+
+
def _has_test_segment(
segments: list[str], original: list[str], filename: str, language: str | None
) -> bool:
@@ -520,7 +555,9 @@ def _classify(
)
if (
needs_test_dir
- and not _is_test_dir(segments, original_segments, filename, language)
+ and not _is_test_dir(
+ *_tree_segments(segments, original_segments, filename), filename, language
+ )
and not _dotnet_project_collects(path, filename, dotnet_projects)
):
return ""
@@ -624,14 +661,15 @@ def in_test_tree(path: str, language: str | None = None) -> bool:
"""Whether a directory alone makes *path* test material, whatever its name.
``tests/x.py`` and ``src/__mocks__/api.ts`` are; ``core/test_selection.py``
- is test-shaped only by name. ``.github/`` makes no test tree.
+ is test-shaped only by name. ``.github/`` makes no test tree, and neither
+ does ``src/**/tests/`` for a JavaScript-family file.
"""
original, lowered = _parts(path)
segments = lowered[:-1]
if not segments or _REPO_METADATA_DIR in segments:
return False
return any(_is_support_anywhere_dir(seg) for seg in segments) or _is_test_dir(
- segments, original[:-1], "", language
+ *_tree_segments(segments, original[:-1], original[-1]), "", language
)
diff --git a/packages/core/src/repowise/core/upgrade/version.py b/packages/core/src/repowise/core/upgrade/version.py
index 38afe9553..7473ca0d6 100644
--- a/packages/core/src/repowise/core/upgrade/version.py
+++ b/packages/core/src/repowise/core/upgrade/version.py
@@ -105,7 +105,10 @@ STORE_FORMAT_VERSION: int = 2
#: A top-level Kotlin declaration with two annotations (``@Preview @Composable
#: private fun f()``) that the grammar read as an expression is re-parsed with its
#: leading annotations blanked, so it becomes a symbol again.
-PARSER_SCHEMA_VERSION: int = 9
+#:
+#: v10: a JavaScript-family file under a ``tests/`` folder inside a ``src`` tree
+#: is not a test by that folder alone, which moves its stored ``is_test``.
+PARSER_SCHEMA_VERSION: int = 10
#: state.json key holding the store format version that wrote the store.
STORE_FORMAT_VERSION_KEY = "store_format_version"
diff --git a/tests/unit/analysis/test_actions_rules.py b/tests/unit/analysis/test_actions_rules.py
index bd91353cb..039b47dec 100644
--- a/tests/unit/analysis/test_actions_rules.py
+++ b/tests/unit/analysis/test_actions_rules.py
@@ -894,3 +894,25 @@ def test_history_at_the_busy_floor_or_uncounted_is_not_flagged() -> None:
facts = _facts(files, history_commits=commits)
assert build_context(facts).history_too_short is False
assert _run(code.fragile_file, facts).status == "evaluated"
+
+
+def _dead_row(path: str) -> dict:
+ return {"id": path, "kind": "unused_export", "file_path": path, "symbol_name": "old",
+ "lines": 5, "safe_to_delete": True, "status": "open"}
+
+
+def test_dead_code_actions_skip_tests_by_the_shared_classifier() -> None:
+ from repowise.core.analysis.actions.build import build_dead
+
+ paths = ("src/components/tests/tests-view.tsx", "src/components/foo.test.ts")
+ dead = build_dead([_dead_row(p) for p in paths], {})
+ assert [d.file_path for d in dead["dead"]] == ["src/components/tests/tests-view.tsx"]
+
+
+def test_dead_code_actions_read_the_stored_test_flag_first() -> None:
+ from repowise.core.analysis.actions.build import build_dead
+
+ path = "core/check_test.py"
+ stored = {path: _file(path, is_test=False)}
+ assert [d.file_path for d in build_dead([_dead_row(path)], stored)["dead"]] == [path]
+ assert build_dead([_dead_row(path)], {})["dead"] == ()
diff --git a/tests/unit/analysis/test_kg_skip_logic.py b/tests/unit/analysis/test_kg_skip_logic.py
index fd771ef8c..074324ede 100644
--- a/tests/unit/analysis/test_kg_skip_logic.py
+++ b/tests/unit/analysis/test_kg_skip_logic.py
@@ -210,7 +210,7 @@ class TestFingerprintDeterminism:
one: whoever bumps the constant updates this line and sees, in the
diff, that they are asking every existing store to re-curate.
"""
- assert knowledge_graph.KG_BUILDER_VERSION == "6"
+ assert knowledge_graph.KG_BUILDER_VERSION == "7"
# ---------------------------------------------------------------------------
diff --git a/tests/unit/health/test_coverage_parsers.py b/tests/unit/health/test_coverage_parsers.py
index 0fe15c0e4..114545a6e 100644
--- a/tests/unit/health/test_coverage_parsers.py
+++ b/tests/unit/health/test_coverage_parsers.py
@@ -298,6 +298,17 @@ def test_is_test_file(path: str, expected: bool) -> None:
assert is_test_file(path) is expected
+def test_is_test_file_honours_pytest_roots() -> None:
+ from repowise.core.pytest_roots import read_pytest_roots
+
+ roots = read_pytest_roots(
+ [("pyproject.toml", '[tool.pytest.ini_options]\ntestpaths = ["tests"]\n')]
+ )
+ assert is_test_file("core/test_selection.py") is True
+ assert is_test_file("core/test_selection.py", roots=roots) is False
+ assert is_test_file("tests/test_selection.py", roots=roots) is True
+
+
def test_is_test_file_uses_source_imports() -> None:
src = "import pytest\n\ndef test_x():\n pass\n"
assert is_test_file("weird/path/name.py", src) is True
diff --git a/tests/unit/health/test_cross_file_oracle.py b/tests/unit/health/test_cross_file_oracle.py
index 43d17c4f3..09940dc73 100644
--- a/tests/unit/health/test_cross_file_oracle.py
+++ b/tests/unit/health/test_cross_file_oracle.py
@@ -38,14 +38,16 @@ def _require(language: str) -> None:
class _FI:
- def __init__(self, path: str, language: str) -> None:
+ def __init__(self, path: str, language: str, is_test: bool | None) -> None:
self.path = path
self.language = language
+ if is_test is not None:
+ self.is_test = is_test
class _PF:
- def __init__(self, path: str, language: str) -> None:
- self.file_info = _FI(path, language)
+ def __init__(self, path: str, language: str, is_test: bool | None = None) -> None:
+ self.file_info = _FI(path, language, is_test)
def _build(tmp_path: Path, files: dict[str, str]):
@@ -68,7 +70,12 @@ def _build(tmp_path: Path, files: dict[str, str]):
for pf in parsed:
rel = pf.file_info.path
source = (tmp_path / rel).read_bytes()
- walked.append((_PF(rel, pf.file_info.language), walk_file(rel, pf.file_info.language, source)))
+ walked.append(
+ (
+ _PF(rel, pf.file_info.language, pf.file_info.is_test),
+ walk_file(rel, pf.file_info.language, source),
+ )
+ )
return walked, gb.graph()
@@ -402,6 +409,44 @@ def test_a_bare_assert_in_production_code_is_not_an_oracle(tmp_path: Path) -> No
assert _flagged(walked, graph, "tests/test_service.py") == ["test_load_runs"]
+def test_an_asserting_module_pytest_does_not_collect_is_not_an_oracle(tmp_path: Path) -> None:
+ """A test-named production module is production when pytest's config says so.
+
+ ``app/test_checks.py`` sits outside ``testpaths``, so ingestion stores it as
+ production, and its ``assert`` must not suppress the test that calls it.
+ """
+ _require("python")
+ walked, graph = _build(
+ tmp_path,
+ {
+ "pyproject.toml": '[tool.pytest.ini_options]\ntestpaths = ["tests"]\n',
+ "app/test_checks.py": (
+ "def check(value):\n"
+ " assert value, 'value required'\n"
+ " return value\n"
+ ),
+ "tests/test_service.py": (
+ "from app.test_checks import check\n"
+ "\n"
+ "def test_check_runs():\n"
+ " check('x')\n"
+ ),
+ },
+ )
+ assert _flagged(walked, graph, "tests/test_service.py") == ["test_check_runs"]
+
+
+def test_test_cases_in_a_stored_production_file_are_not_candidates(tmp_path: Path) -> None:
+ """The stored flag decides; the path rule answers only when none was stored."""
+ from repowise.core.analysis.health.asserts.oracle_reach import _candidates
+
+ _require("python")
+ source = b"def test_connection():\n ping()\n"
+ fcx = walk_file("app/test_runner.py", "python", source)
+ assert _candidates(_PF("app/test_runner.py", "python", is_test=False), fcx) == []
+ assert _candidates(_PF("app/test_runner.py", "python"), fcx) != []
+
+
def test_a_call_the_graph_cannot_resolve_suppresses_nothing(tmp_path: Path) -> None:
"""An unresolved call is indistinguishable from a call that checks nothing."""
_require("python")
diff --git a/tests/unit/health/test_model_version_coupling.py b/tests/unit/health/test_model_version_coupling.py
index b94d793dc..ea2caae4d 100644
--- a/tests/unit/health/test_model_version_coupling.py
+++ b/tests/unit/health/test_model_version_coupling.py
@@ -22,7 +22,7 @@ from repowise.core.analysis.health.refactoring.identity import (
# The three stamps as they stand together. Moving either identity model means
# moving the analyzer with it, and updating this tuple in the same commit.
-_STAMPS = (41, 3, 4)
+_STAMPS = (42, 3, 4)
def test_the_identity_models_and_the_analyzer_stamp_are_pinned_together() -> None:
diff --git a/tests/unit/test_code_origin.py b/tests/unit/test_code_origin.py
index 77d407491..06b745ecc 100644
--- a/tests/unit/test_code_origin.py
+++ b/tests/unit/test_code_origin.py
@@ -47,6 +47,10 @@ _OWN_HEADER = (
("pkg/external/client.go", "production"), # external/ only at the root
("tests/test_app.py", "test"),
("src/app.test.ts", "test"),
+ # a `tests/` folder inside a JS-family `src` tree is a product feature
+ ("packages/web/src/app/repos/[id]/tests/page.tsx", "production"),
+ ("packages/web/src/components/tests/tests-view.tsx", "production"),
+ ("packages/web/src/components/tests/tests-view.test.tsx", "test"),
("vendor/github.com/x/y.go", "vendored"),
("web/node_modules/lodash/index.js", "vendored"),
("static/bower_components/jquery/jquery.js", "vendored"),
diff --git a/tests/unit/test_test_paths.py b/tests/unit/test_test_paths.py
index a98f608c3..85483feef 100644
--- a/tests/unit/test_test_paths.py
+++ b/tests/unit/test_test_paths.py
@@ -50,6 +50,22 @@ _CORPUS: tuple[tuple[str, str | None, str], ...] = (
("src/foo.test.mts", None, "test"),
("src/foo.spec.cts", None, "test"),
("src/foo.mts", None, ""),
+ # inside a JS-family `src` tree a `tests/` folder is a product feature unless
+ # the file name or another test dir says otherwise; outside `src` it is a
+ # suite, the way Mocha, AVA and `node --test` collect a whole folder
+ ("packages/web/src/app/repos/[id]/tests/page.tsx", None, ""),
+ ("packages/web/src/components/tests/tests-view.tsx", None, ""),
+ ("src/components/tests/TestsView.vue", None, ""),
+ ("Src/Tests/page.svelte", None, ""),
+ ("packages/web/tests/page.tsx", None, "test"),
+ ("src/components/tests/Button.test.tsx", None, "test"),
+ ("src/__tests__/tests/helpers.ts", None, "test"),
+ ("src/tests/__mocks__/api.ts", None, "support"),
+ ("web/src/test/setup.ts", None, "test"),
+ ("tests/foo.test.ts", None, "test"),
+ ("tests/utils.ts", None, "test"),
+ ("test/app.router.js", None, "test"),
+ ("pkg/src/tests/helpers.py", None, "test"),
# maven / gradle / kotlin multiplatform
("src/test/java/Foo.java", None, "test"),
("src/it/scala/FooSpec.scala", None, "test"),
@@ -358,6 +374,8 @@ def test_degenerate_paths_are_not_tests(path: str) -> None:
[
("tests/x.py", True),
("src/__mocks__/api.ts", True),
+ ("packages/web/src/components/tests/tests-view.tsx", False),
+ ("pkg/src/tests/helpers.py", True),
("pkg/tests/helpers/db.py", True),
("packages/core/src/pkg/core/test_selection.py", False),
("src/bot.test-harness.ts", False),