test: run the desktop unit tests on Node 25 by Zane-0x5a · Pull Request #5666 · marktext/marktext · GitHub
Skip to content

test: run the desktop unit tests on Node 25 - #5666

Merged
Jocs merged 2 commits into
marktext:developfrom
Zane-0x5a:fix/node25-unit-tests
Oct 9, 2026
Merged

Jocs merged 2 commits into
marktext:developfrom
Zane-0x5a:fix/node25-unit-tests

Conversation

@Zane-0x5a

Copy link
Copy Markdown
Contributor

Summary

On Node 25, pnpm test fails the specs in packages/desktop that touch storage, for example all four in export-settings-persist.spec.ts:

TypeError: localStorage.clear is not a function

Node 25 enables its Web Storage API by default. The global localStorage it defines shadows the one jsdom installs, and without --localstorage-file it has no working methods.

This passes --no-experimental-webstorage to the Vitest workers (test.execArgv). Node 20.19, the minimum in engines, does not know the flag and would refuse to start the worker, so it is passed only when process.allowedNodeEnvironmentFlags has it. CI (Node 22 and 24) is unaffected either way.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • New tests added (or explain why not needed): the existing storage specs are the test.
  • Manually tested on: Windows 11, Node 25.2.1. Before: export-settings-persist.spec.ts fails 4 tests as above. After: the whole desktop unit suite passes (88 files, 1032 tests) without any NODE_OPTIONS.

Notes for reviewers [optional]

No screenshots: only the unit test configuration changes. packages/muya uses happy-dom and already passes on Node 25.


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

🤖 Generated with Claude Code

Node 25 enables its Web Storage API by default. Its global localStorage
shadows the one jsdom installs, and without --localstorage-file its
methods are missing, so every spec that touches storage fails with
'localStorage.clear is not a function'.

Pass --no-experimental-webstorage to the test workers when the running
Node knows the flag; Node 20 would reject it.
Node 25 accepts `--no-experimental-webstorage` but only lists
`--experimental-webstorage` in `allowedNodeEnvironmentFlags` (25.0.0 lists
`--experimental-webstorage`, `--webstorage` and `--no-webstorage`, but not
the negated experimental spelling). The guard was therefore false on that
release and the flag never reached the workers, leaving the storage specs
failing.

Probe the positive spelling instead: Node 20 has no feature flag (so no
flag is passed), and Node 22/24 list both spellings.

Verified on Node 25.0.0: `pnpm test` is green without NODE_OPTIONS.
@Jocs
Jocs merged commit eabd0a7 into marktext:develop Oct 9, 2026
10 checks passed
@Zane-0x5a
Zane-0x5a deleted the fix/node25-unit-tests branch October 9, 2026 09:04
Zane-0x5a added a commit to Zane-0x5a/marktext that referenced this pull request Oct 9, 2026
Takes upstream's Node 25 web storage probe from marktext#5666 over the fork's
earlier spelling, and regenerates the lockfile from upstream's with
pdfjs-dist added for the print preview.
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.

2 participants