fix(tests): handle new tests with no snapshot

This commit is contained in:
2026-05-29 18:44:28 +02:00
parent e2d5943517
commit 9dd547d6c1

View File

@@ -54,8 +54,11 @@ class Tester(ABC):
return failures == 0 return failures == 0
def _run_test(self, path: Path) -> bool: def _run_test(self, path: Path) -> bool:
result: CaseResult = self._exec_case(path)
result_path: Path = self._result_path(path) result_path: Path = self._result_path(path)
if not result_path.exists():
print("Missing snapshot. Please run the update command first")
return False
result: CaseResult = self._exec_case(path)
expected: str = result_path.read_text() expected: str = result_path.read_text()
actual: str = result.dumps() actual: str = result.dumps()
@@ -88,7 +91,7 @@ class Tester(ABC):
def _update_test(self, path: Path) -> bool: def _update_test(self, path: Path) -> bool:
result: CaseResult = self._exec_case(path) result: CaseResult = self._exec_case(path)
result_path: Path = self._result_path(path) result_path: Path = self._result_path(path)
current: str = result_path.read_text() current: str = result_path.read_text() if result_path.exists() else ""
new: str = result.dumps() new: str = result.dumps()
if current == new: if current == new:
return False return False