diff --git a/spec/tests/test-hyperscript-behavioral.sx b/spec/tests/test-hyperscript-behavioral.sx index 7948bdac..a52b623b 100644 --- a/spec/tests/test-hyperscript-behavioral.sx +++ b/spec/tests/test-hyperscript-behavioral.sx @@ -2213,41 +2213,75 @@ ;; ── core/runtimeErrors (18 tests) ── (defsuite "hs-upstream-core/runtimeErrors" (deftest "reports basic function invocation null errors properly" - (error "SKIP (untranslated): reports basic function invocation null errors properly")) + (hs-cleanup!) + (assert= (eval-hs-error "x()") "'x' is null") + (assert= (eval-hs-error "x.y()") "'x' is null") + (assert= (eval-hs-error "x.y.z()") "'x.y' is null")) (deftest "reports basic function invocation null errors properly w/ of" - (error "SKIP (untranslated): reports basic function invocation null errors properly w/ of")) + (hs-cleanup!) + (assert= (eval-hs-error "z() of y of x") "'z' is null")) (deftest "reports basic function invocation null errors properly w/ possessives" - (error "SKIP (untranslated): reports basic function invocation null errors properly w/ possessives")) + (hs-cleanup!) + (assert= (eval-hs-error "x's y()") "'x' is null") + (assert= (eval-hs-error "x's y's z()") "'x's y' is null")) (deftest "reports null errors on add command properly" - (error "SKIP (untranslated): reports null errors on add command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "add .foo to #doesntExist") "'#doesntExist' is null") + (assert= (eval-hs-error "add @foo to #doesntExist") "'#doesntExist' is null") + (assert= (eval-hs-error "add {display:none} to #doesntExist") "'#doesntExist' is null")) (deftest "reports null errors on decrement command properly" - (error "SKIP (untranslated): reports null errors on decrement command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "decrement #doesntExist's innerHTML") "'#doesntExist' is null")) (deftest "reports null errors on default command properly" - (error "SKIP (untranslated): reports null errors on default command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "default #doesntExist's innerHTML to 'foo'") "'#doesntExist' is null")) (deftest "reports null errors on hide command properly" - (error "SKIP (untranslated): reports null errors on hide command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "hide #doesntExist") "'#doesntExist' is null")) (deftest "reports null errors on increment command properly" - (error "SKIP (untranslated): reports null errors on increment command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "increment #doesntExist's innerHTML") "'#doesntExist' is null")) (deftest "reports null errors on measure command properly" - (error "SKIP (untranslated): reports null errors on measure command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "measure #doesntExist") "'#doesntExist' is null")) (deftest "reports null errors on put command properly" - (error "SKIP (untranslated): reports null errors on put command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "put 'foo' into #doesntExist") "'#doesntExist' is null") + (assert= (eval-hs-error "put 'foo' into #doesntExist's innerHTML") "'#doesntExist' is null") + (assert= (eval-hs-error "put 'foo' into #doesntExist.innerHTML") "'#doesntExist' is null") + (assert= (eval-hs-error "put 'foo' before #doesntExist") "'#doesntExist' is null") + (assert= (eval-hs-error "put 'foo' after #doesntExist") "'#doesntExist' is null") + (assert= (eval-hs-error "put 'foo' at the start of #doesntExist") "'#doesntExist' is null") + (assert= (eval-hs-error "put 'foo' at the end of #doesntExist") "'#doesntExist' is null")) (deftest "reports null errors on remove command properly" - (error "SKIP (untranslated): reports null errors on remove command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "remove .foo from #doesntExist") "'#doesntExist' is null") + (assert= (eval-hs-error "remove @foo from #doesntExist") "'#doesntExist' is null") + (assert= (eval-hs-error "remove #doesntExist from #doesntExist") "'#doesntExist' is null")) (deftest "reports null errors on send command properly" - (error "SKIP (untranslated): reports null errors on send command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "send 'foo' to #doesntExist") "'#doesntExist' is null")) (deftest "reports null errors on sets properly" - (error "SKIP (untranslated): reports null errors on sets properly")) + (hs-cleanup!) + (assert= (eval-hs-error "set x's y to true") "'x' is null") + (assert= (eval-hs-error "set x's @y to true") "'x' is null")) (deftest "reports null errors on settle command properly" - (error "SKIP (untranslated): reports null errors on settle command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "settle #doesntExist") "'#doesntExist' is null")) (deftest "reports null errors on show command properly" - (error "SKIP (untranslated): reports null errors on show command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "show #doesntExist") "'#doesntExist' is null")) (deftest "reports null errors on toggle command properly" - (error "SKIP (untranslated): reports null errors on toggle command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "toggle .foo on #doesntExist") "'#doesntExist' is null") + (assert= (eval-hs-error "toggle between .foo and .bar on #doesntExist") "'#doesntExist' is null") + (assert= (eval-hs-error "toggle @foo on #doesntExist") "'#doesntExist' is null")) (deftest "reports null errors on transition command properly" - (error "SKIP (untranslated): reports null errors on transition command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "transition #doesntExist's *visibility to 0") "'#doesntExist' is null")) (deftest "reports null errors on trigger command properly" - (error "SKIP (untranslated): reports null errors on trigger command properly")) + (hs-cleanup!) + (assert= (eval-hs-error "trigger 'foo' on #doesntExist") "'#doesntExist' is null")) ) ;; ── core/scoping (20 tests) ── diff --git a/tests/playwright/generate-sx-tests.py b/tests/playwright/generate-sx-tests.py index 2cbc0ab5..1cb20d69 100644 --- a/tests/playwright/generate-sx-tests.py +++ b/tests/playwright/generate-sx-tests.py @@ -2318,6 +2318,13 @@ def generate_eval_only_test(test, idx): lines = [] safe_name = sx_name(test['name']) + # runtimeErrors: expect(await error("EXPR")).toBe("MSG") → eval-hs-error + if 'await error(' in body: + error_pats = re.findall(r'expect\(await error\("([^"]+)"\)\)\.toBe\("([^"]+)"\)', body) + if error_pats: + asserts = '\n'.join(f' (assert= (eval-hs-error "{e}") "{m}")' for e, m in error_pats) + return f' (deftest "{safe_name}"\n (hs-cleanup!)\n{asserts})' + # Special case: cluster-33 cookie tests. Each test calls a sequence of # `_hyperscript("HS")` inside `page.evaluate(()=>{...})`. The runner backs # `cookies` with a Proxy over a per-test `__hsCookieStore` map (see