Skip to content

Add Vitest test suite for pure-logic modules - #1927

Open
sweenzor wants to merge 2 commits into
gildas-lormeau:masterfrom
sweenzor:test-suite
Open

Add Vitest test suite for pure-logic modules#1927
sweenzor wants to merge 2 commits into
gildas-lormeau:masterfrom
sweenzor:test-suite

Conversation

@sweenzor

@sweenzor sweenzor commented Mar 20, 2026

Copy link
Copy Markdown

Some ideas about how a test suite for SingleFile might look. Let me know your thoughts @gildas-lormeau!

Summary

  • Add Vitest with 103 tests covering pure-logic modules that don't require browser APIs
  • Test srcset parser, MHTML utilities (including decodeBinary/decodeBase64), yabson serialization round-trips, and config/download helpers
  • Extract pure functions from config.js and downloads.js into config-utils.js so they are importable without browser dependencies
  • Add @eslint/js to devDependencies: eslint.config.mjs imports it, but ESLint 10 no longer ships it as a transitive dependency, so npx eslint . fails on a fresh checkout without it

Test plan

  • npm test -- all 103 tests pass
  • npm run build -- rollup build still succeeds (confirms extraction didn't break imports)
  • npx eslint . -- no lint errors in new/modified files (downloads.js has pre-existing preserve-caught-error hits from ESLint 10's new recommended rule, unrelated to this change)

@@ -0,0 +1,99 @@
/*
* Copyright 2010-2020 Gildas Lormeau

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Suggested change
* Copyright 2010-2020 Gildas Lormeau
* Copyright 2010-2026 Gildas Lormeau

sweenzor and others added 2 commits July 10, 2026 10:51
Test srcset parser, MHTML utilities, yabson serialization round-trips,
and config/download helpers. Extract pure functions from config.js and
downloads.js into config-utils.js to make them importable without
browser API dependencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove unused MIGRATION_DEFAULT_VARIABLES_VALUES import in config.js
  (only updateFilenameTemplate needs it, and it lives in config-utils.js)
- Declare TextEncoder/atob globals in mhtml-util.test.js so the test
  file passes eslint
- Add @eslint/js to devDependencies: eslint.config.mjs imports it, but
  eslint 10 no longer ships it as a transitive dependency, so
  "npx eslint ." fails on a fresh checkout
- Add tests for decodeBinary and decodeBase64 (base64 encoding of the
  full byte range, chunk-boundary-sized input, charset handling)
- Collapse leftover double blank lines where functions were extracted

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sweenzor
sweenzor marked this pull request as ready for review July 11, 2026 17:00
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.

1 participant