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.
After FF-2's
chrome.* → browser.*migration, production code in@gitmarks/extension-sharedcallsbrowser.bookmarks.create(...)etc., but the existing test assertions still referencechrome.bookmarks.create:(~24 such assertions across apply-remote, listeners, reconcile, save-flow tests.)
These pass today because
test/setup.ts:64-65stubs BOTHglobalThis.chromeANDglobalThis.browserto the SAMEchromeStubobject —chrome.bookmarks.createandbrowser.bookmarks.createare the samevi.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 checkchrome,.mock.callsreturns empty.Fix
Rewrite the assertions in terms of either:
browser.bookmarks.createdirectly (most natural — matches production)chromeStub.bookmarks.createvia an import from the setup (most explicit about the shared mock)Flagged by
Post-merge code review of PR #32.