Skip to content

Run template JS tests with node:test instead of mini_racer - #1863

Open
st0012 wants to merge 1 commit into
masterfrom
claude/project-thread-kiqk61
Open

st0012 wants to merge 1 commit into
masterfrom
claude/project-thread-kiqk61

Conversation

@st0012

@st0012 st0012 commented Oct 26, 2026

Copy link
Copy Markdown
Member

Requested by Stan · project thread

The JS tests for the Aliki highlighters, the Aliki search ranker and controller, and the json_index searcher now run with Node's built-in test runner (npm run test:js). The Lint workflow runs them. mini_racer is no longer a development dependency.

Before this change, these tests were Ruby files that evaluated the JS through mini_racer. They were skipped on Windows, JRuby and TruffleRuby, and anywhere mini_racer did not install. The highlighter tests also rewrote the script source with regexes to remove the IIFE wrapper.

Now a small helper loads the template scripts into a vm context, the same way a page loads them as classic scripts with shared globals. The highlighter tests use a small fake document and go through the real DOMContentLoaded path. The tests need Node 20 or later and no npm packages. The shipped JS does not change.

The 88 test cases are a direct port of the four Ruby files. aliki.js stays untested for now, because its TOC and sidebar code depends on real layout.


Generated by Claude Code

The JS tests for the Aliki highlighters, the Aliki search ranker and
controller, and the json_index searcher now run with Node's built-in
test runner. They load the template scripts into a vm context, the same
way a page loads them as classic scripts. The highlighter tests drive
the real DOMContentLoaded path through a small fake document, so they
no longer rewrite the script source before they run it.

mini_racer is no longer a development dependency.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G1CzhozGTbKZGZrsPu3LBa
Copilot AI balanced review requested due to automatic review settings October 26, 2026 10:59
@st0012 st0012 self-assigned this Oct 26, 2026
@github-actions

Copy link
Copy Markdown

Documentation preview

View the preview

Commit: c920350

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test command relies on shell wildcard expansion and fails on Windows with the documented Node 20 minimum.

1 open issue
What changed in this PR

Moves RDoc’s template JavaScript tests from mini_racer to Node’s built-in test runner without changing shipped JavaScript.

Changes:

  • Ports 88 tests for highlighting and search to JavaScript, with shared script-loading and DOM helpers.
  • Adds npm run test:js to the Lint workflow and documents the Node requirement.
  • Removes the Ruby test wrappers and mini_racer dependency.
File Description
test/​rdoc/​generator/​json_index/​searcher_test.rb Removes the Ruby searcher tests.
test/​rdoc/​generator/​aliki/​search_test.rb Removes the Ruby ranker and controller tests.
test/​rdoc/​generator/​aliki/​highlight_c_test.rb Removes the Ruby C highlighter tests.
test/​rdoc/​generator/​aliki/​highlight_bash_test.rb Removes the Ruby Bash highlighter tests.
test/​js/​json_index/​searcher.test.js Ports searcher tests to Node.
test/​js/​helper.js Adds shared VM-loading, DOM, and assertion helpers.
test/​js/​aliki/​search.test.js Ports ranker and controller tests to Node.
test/​js/​aliki/​c_highlighter.test.js Ports C highlighting tests through DOM initialization.
test/​js/​aliki/​bash_highlighter.test.js Ports Bash highlighting tests through DOM initialization.
package.json Adds the JavaScript test command.
Gemfile Removes mini_racer.
CONTRIBUTING.md Documents JavaScript test requirements and usage.
.github/​workflows/​lint.yml Runs JavaScript tests in CI.

Review effort: Balanced

Comment thread package.json
"scripts": {
"lint:css": "stylelint 'lib/rdoc/generator/template/**/*.css'"
"lint:css": "stylelint 'lib/rdoc/generator/template/**/*.css'",
"test:js": "node --test test/js/*/*.test.js"

This branch has not been deployed

No deployments
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.

3 participants