kink-discovery / tests /test_frontend_direction_contract_node.py
Perplexed7675's picture
Sync from kink_cli (Docker Space)
2c11dc3 verified
Raw
History Blame Contribute Delete
884 Bytes
"""Run Node contract tests for frontend helpers (``*.test.mjs``)."""
from __future__ import annotations
import shutil
import subprocess
import sys
from pathlib import Path
import pytest
REPO_ROOT = Path(__file__).resolve().parent.parent
@pytest.mark.skipif(shutil.which("node") is None, reason="Node.js not installed")
def test_frontend_contracts_via_node() -> None:
tests = sorted((REPO_ROOT / "frontend").glob("*.test.mjs"))
for t in tests:
assert t.is_file(), t
proc = subprocess.run(
[shutil.which("node") or "node", "--test", *[str(t) for t in tests]],
cwd=str(REPO_ROOT),
capture_output=True,
text=True,
timeout=60,
)
if proc.returncode != 0:
sys.stderr.write(proc.stdout or "")
sys.stderr.write(proc.stderr or "")
assert proc.returncode == 0, "node --test frontend/*.test.mjs failed"