Skip to content

Improve asserting element equality in tests - #211

Merged
jzheaux merged 18 commits into
jzheaux:mainfrom
Ptraaah:fix/167-element-asserts
Nov 3, 2026
Merged

jzheaux merged 18 commits into
jzheaux:mainfrom
Ptraaah:fix/167-element-asserts

Conversation

@Ptraaah

@Ptraaah Ptraaah commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #167.

test/dom.js gains assertElement and assertNotElement. They compare elements by identity and fail at once, naming each element by its tag, id and classes, so a failing check says what was expected and what was there instead of describing the whole element for its message. Every element assert in the suite moves onto them (48 call sites): the assert.equal and assert.notEqual ones on document.activeElement, and the assert.ok(a === b) / !== workarounds, keeping their messages. CI's test job gets timeout-minutes: 10, so a hang can't hold a run for hours.

What I ran locally:

  • Before: on the app's own page, assert.equal(document.activeElement, document.body) with the keyboard on a button took 17.7 seconds to fail, all of it spent describing the button. The same check through assertElement fails in milliseconds: expected body, got button#sidebarToggle.ghost.icon.
  • The check from the issue: in test/focus.test.js, I pointed one assert at the wrong element and ran the file. It failed in seconds with expected button#newBtn.ghost.small, got input#newName. Put back afterwards.
  • npm test before the change: 777 tests, 775 pass, 1 skipped, and one failure in test/cli.test.js (a frame-port test, unrelated to this; it passed on the after run). After: 777 tests, 776 pass, 0 fail, 1 skipped. Lint is clean on the touched files.

@jzheaux jzheaux changed the title Fail a check on an element fast, naming the elements, instead of hanging the run Improve asserting element equality in tests Nov 3, 2026
@jzheaux jzheaux self-assigned this Nov 3, 2026
@jzheaux jzheaux added this to the 0.0.4 milestone Nov 3, 2026
Ptraaah and others added 18 commits November 2, 2026 23:59
A stuck job would otherwise hold a pull request for GitHub's default of
six hours. No job has reached a minute, so 5 minutes means something's
stuck, not slow, and the workflow says so, to let the number be
questioned later.

Closes jzheauxgh-229

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Josh Cummings <[email protected]>
These four checks compared two elements with assert.equal or
assert.ok(a === b), so a failure would either hang the run or say
nothing. Now they name both elements, as the rest do.

Closes jzheauxgh-167

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Josh Cummings <[email protected]>
@jzheaux
jzheaux force-pushed the fix/167-element-asserts branch from 309afa3 to b439238 Compare November 3, 2026 06:59
@jzheaux
jzheaux merged commit e99606c into jzheaux:main Nov 3, 2026
2 checks passed
@jzheaux

jzheaux commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Thank you, @Ptraaah, for these careful changes! They are now merged into main and are scheduled for milestone 0.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A failing check on a page's element should fail the test, not hang it

2 participants