fix(test): install node instead of dying on its absence

test-unit-javascript ran `node --test` without declaring where node
comes from, while its python sibling declares `install`. On a bare
distro image the target died with `exec: node: not found` (127), which
took down the pre-commit hook and all five test-workspace jobs.

The installer stack already knows how to pull a command from the system
package manager; node was simply missing from the table. Wiring the
target to install-node provisions it the same way php, ruby and npm are
provisioned, and fails loudly when the runtime cannot be installed
rather than skipping the suite.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5 committed 2026-08-22 13:01:36 +02:00
1 parent e17d004e17
commit ce244132a6
5 files changed
+95 -2

No files matched your search

@@ -0,0 +1,41 @@
"""Unit tests for :mod:`utils.install.node`."""
from __future__ import annotations
import unittest
import unittest.mock as mock
from utils.install import node as node_mod
class TestEnsureNodePresent(unittest.TestCase):
def test_present_noop(self) -> None:
with (
mock.patch.object(node_mod.shutil, "which", return_value="/usr/bin/node"),
mock.patch.object(node_mod, "install_command_via_pkg") as install_pkg,
):
node_mod.ensure_node_present()
install_pkg.assert_not_called()
def test_installs_via_system_pkg(self) -> None:
whiches = iter([None, "/usr/bin/node"])
with (
mock.patch.object(
node_mod.shutil, "which", side_effect=lambda _x: next(whiches)
),
mock.patch.object(node_mod, "install_command_via_pkg") as install_pkg,
):
node_mod.ensure_node_present()
install_pkg.assert_called_once_with("node")
def test_raises_when_still_missing(self) -> None:
with (
mock.patch.object(node_mod.shutil, "which", return_value=None),
mock.patch.object(node_mod, "install_command_via_pkg"),
self.assertRaises(RuntimeError),
):
node_mod.ensure_node_present()
if __name__ == "__main__":
unittest.main()