diff --git a/hosts/ocaml/bin/run_tests.ml b/hosts/ocaml/bin/run_tests.ml index 8e4ff395..656f1731 100644 --- a/hosts/ocaml/bin/run_tests.ml +++ b/hosts/ocaml/bin/run_tests.ml @@ -1559,6 +1559,10 @@ let run_spec_tests env test_files = match args with | [String "document"] -> mock_document | [String "window"] -> Nil (* self-referential, not needed for tests *) + | [String "console"] -> + let d = Hashtbl.create 4 in + Hashtbl.replace d "__mock_type" (String "console"); + Dict d | [String name] -> (* Check SX env for globally defined things like "tmp" used in HS tests *) (try Sx_types.env_get env name with _ -> Nil) @@ -1798,6 +1802,10 @@ let run_spec_tests env test_files = | _ -> String "") | _ -> Nil) + else if mt = "console" then + (* console.log/debug/error — no-op in tests *) + Nil + else (* Element methods *) (match m with @@ -2206,6 +2214,10 @@ let run_spec_tests env test_files = load_module "runtime.sx" hs_dir; load_module "integration.sx" hs_dir; load_module "htmx.sx" hs_dir; + (* Override console-log to avoid str on circular mock DOM refs *) + ignore (Sx_types.env_bind env "console-log" (NativeFn ("console-log", fun _ -> Nil))); + ignore (Sx_types.env_bind env "console-debug" (NativeFn ("console-debug", fun _ -> Nil))); + ignore (Sx_types.env_bind env "console-error" (NativeFn ("console-error", fun _ -> Nil))); (* eval-hs: compile hyperscript source to SX and evaluate it. Used by eval-only behavioral tests (comparisonOperator, mathOperator, etc.) *) ignore (Sx_types.env_bind env "eval-hs" (NativeFn ("eval-hs", fun args ->