Skip to content

Test assertions target chrome.bookmarks.* while production calls browser.bookmarks.* #35

@paperhurts

Description

@paperhurts

After FF-2's chrome.* → browser.* migration, production code in @gitmarks/extension-shared calls browser.bookmarks.create(...) etc., but the existing test assertions still reference chrome.bookmarks.create:

// packages/extension-shared/test/apply-remote.test.ts
expect(chrome.bookmarks.create).toHaveBeenCalledWith(...)

(~24 such assertions across apply-remote, listeners, reconcile, save-flow tests.)

These pass today because test/setup.ts:64-65 stubs BOTH globalThis.chrome AND globalThis.browser to the SAME chromeStub object — chrome.bookmarks.create and browser.bookmarks.create are the same vi.fn.

Fragility

A future contributor 'fixing' the stub to give chrome and browser distinct mock objects (e.g., to test polyfill-shim behavior) silently breaks every assertion — production calls browser, the assertions check chrome, .mock.calls returns empty.

Fix

Rewrite the assertions in terms of either:

  • browser.bookmarks.create directly (most natural — matches production)
  • chromeStub.bookmarks.create via an import from the setup (most explicit about the shared mock)

Flagged by

Post-merge code review of PR #32.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions