Skip to content

test: add hermetic unit suite and wire it into CI#201760

Open
victalejo wants to merge 1 commit into
wwebjs:mainfrom
victalejo:main
Open

test: add hermetic unit suite and wire it into CI#201760
victalejo wants to merge 1 commit into
wwebjs:mainfrom
victalejo:main

Conversation

@victalejo
Copy link
Copy Markdown

Summary

Splits tests/ into two tiers so CI actually runs tests on every push:

  • tests/unit/ — 74 hermetic tests (~150 ms) covering structures, factories,
    Util, web cache backends, and auth strategies. No Chromium, no network,
    no WhatsApp session required.
  • tests/integration/ — the existing E2E suite, unchanged in behavior; moved
    with git mv to preserve history.

Also fixes the Tests workflow, which was mis-wired to run npm run lint
(duplicating lint.yml). It now runs the unit suite across Node 18 / 20 / 22.

Changes

  • New tests/unit/ covering:
    • Structures: Location, Poll, Label, Reaction, Buttons, List,
      MessageMedia (constructor + fromFilePath + fromUrl mime guard)
    • Util.generateHash, Util.mergeDefault, constructor guard
    • LocalAuth (clientId validation, path resolution, beforeBrowserInitialized
      in a temp dir), NoAuth
    • WebCache, LocalWebCache (persist/resolve/strict), RemoteWebCache
      constructor validation, WebCacheFactory
    • ChatFactory, ContactFactory
  • package.json:
    • npm testtest:unit (new default; previously failed without a real
      phone number)
    • npm run test:unit → fast suite
    • npm run test:integration → existing E2E suite
  • .github/workflows/tests.yml: runs npm run test:unit on Node 18/20/22
    with npm caching, instead of duplicating the lint job.
  • Docs: top-level tests/README.md explaining the two tiers,
    tests/integration/README.md updated with the new command.

splits tests/ into two tiers so CI actually runs tests on every push.

- tests/unit/ — 74 hermetic tests (~150 ms) covering structures, factories,
  Util, web cache backends, and auth strategies. No Chromium, no network,
  no WhatsApp session required.
- tests/integration/ — the existing E2E suite, unchanged in behavior;
  moved with `git mv` to preserve history.

also fixes the Tests workflow, which was mis-wired to run `npm run lint`
(duplicating lint.yml). It now runs the unit suite across Node 18/20/22.

package.json:
- npm test → test:unit (new default; previously failed without a phone)
- npm run test:unit → fast suite
- npm run test:integration → existing E2E suite
@github-actions github-actions Bot added docs Documentation changes dependencies Dependency updates tests Test related ci CI pipeline infra Infrastructure labels May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI pipeline dependencies Dependency updates docs Documentation changes infra Infrastructure tests Test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant