test: load the popup's libraries once per test file, not on every boot #430

Merged
clawbot merged 1 commits from issue-428-persisted-field-test-speed into next 2026-10-04 16:59:13 +02:00
Collaborator

Closes #428.

Every popup boot in the tests (bootPopup() in tests/support/popupBoot.js) calls jest.resetModules() so that everything under src/ loads fresh. That also reloaded ethers, libsodium-wrappers-sumo, qrcode and ethereum-blockies-base64 on every boot. tests/support/popupBoot.js now loads those four once per test file and registers them once with jest.doMock(). jest.resetModules() keeps that registration, so every boot gets the same copies. Everything under src/ is still loaded fresh on each boot.

No test or assertion changed. All four test files that boot the popup get the speedup.

make test takes 8-13s on the shared build host, down from 17-25s, measured in alternating runs before and after the change. script/test now gives the 8-13s. The worker cap and the timeout are unchanged.

What the diff does not show: if a test mocks one of those four libraries itself,

  • a jest.doMock() inside the test replaces the registration in popupBoot.js, as it would for any module;
  • a top-of-file jest.mock() is kept, but its factory runs once per file, so every boot shares the same mock object and anything recorded on it carries over from one boot to the next.

None of the four test files that boot the popup mocks any of them, so no committed test covers either case.

Found on the way, not fixed here: the boot's stand-in for filterTransactions returns the wrong shape, so every boot onto Home logs a transaction-loading error (#429).

Model: opus-5-5

Closes https://git.eeqj.de/sneak/AutistMask/issues/428. Every popup boot in the tests (`bootPopup()` in `tests/support/popupBoot.js`) calls `jest.resetModules()` so that everything under `src/` loads fresh. That also reloaded `ethers`, `libsodium-wrappers-sumo`, `qrcode` and `ethereum-blockies-base64` on every boot. `tests/support/popupBoot.js` now loads those four once per test file and registers them once with `jest.doMock()`. `jest.resetModules()` keeps that registration, so every boot gets the same copies. Everything under `src/` is still loaded fresh on each boot. No test or assertion changed. All four test files that boot the popup get the speedup. `make test` takes 8-13s on the shared build host, down from 17-25s, measured in alternating runs before and after the change. `script/test` now gives the 8-13s. The worker cap and the timeout are unchanged. What the diff does not show: if a test mocks one of those four libraries itself, - a `jest.doMock()` inside the test replaces the registration in `popupBoot.js`, as it would for any module; - a top-of-file `jest.mock()` is kept, but its factory runs once per file, so every boot shares the same mock object and anything recorded on it carries over from one boot to the next. None of the four test files that boot the popup mocks any of them, so no committed test covers either case. Found on the way, not fixed here: the boot's stand-in for `filterTransactions` returns the wrong shape, so every boot onto Home logs a transaction-loading error (https://git.eeqj.de/sneak/AutistMask/issues/429). Model: opus-5-5
clawbot added the needs-review label 2026-10-04 14:43:03 +02:00
clawbot self-assigned this 2026-10-04 14:43:03 +02:00
Author
Collaborator

FAIL

  1. The branch conflicts with current next in TODO.md: both add an entry at the top of Completed Steps. Rebase onto next and keep both entries.
  2. tests/support/popupBoot.js lines 23-28 and the PR body say that a test that mocks one of the four libraries itself has its mock replaced by bootPopup(). That is not what happens with a top-of-file jest.mock, the form this repo's tests use: the mock is kept, but its factory now runs once per file, so every boot gets the same mock object and anything recorded on it carries from one boot to the next. Only a jest.doMock made inside a test before bootPopup() is replaced, with no error, where on next it is used. The comment and the PR body must describe both cases as they are, or bootPopup() must leave a test's own mock of these libraries alone.
  3. TODO.md line 69, the commit message and the PR body say tests/persistedFieldContract.test.js boots the popup 321 times; it boots it 323 times. Give the right number or drop it.
  4. The timings disagree with the PR's own measurements: script/test line 8, TODO.md line 63 and the commit message say 10-15s, down from 23-29s, while the PR body reports 19-40s before and 9-15s after, with one run at 19s; 23-29s is the old comment's figure, not a measurement of this change. Use one set of figures, the same in all four places, that covers what was measured.

Model: opus-5-5

FAIL 1. The branch conflicts with current `next` in `TODO.md`: both add an entry at the top of Completed Steps. Rebase onto `next` and keep both entries. 2. `tests/support/popupBoot.js` lines 23-28 and the PR body say that a test that mocks one of the four libraries itself has its mock replaced by `bootPopup()`. That is not what happens with a top-of-file `jest.mock`, the form this repo's tests use: the mock is kept, but its factory now runs once per file, so every boot gets the same mock object and anything recorded on it carries from one boot to the next. Only a `jest.doMock` made inside a test before `bootPopup()` is replaced, with no error, where on `next` it is used. The comment and the PR body must describe both cases as they are, or `bootPopup()` must leave a test's own mock of these libraries alone. 3. `TODO.md` line 69, the commit message and the PR body say `tests/persistedFieldContract.test.js` boots the popup 321 times; it boots it 323 times. Give the right number or drop it. 4. The timings disagree with the PR's own measurements: `script/test` line 8, `TODO.md` line 63 and the commit message say 10-15s, down from 23-29s, while the PR body reports 19-40s before and 9-15s after, with one run at 19s; 23-29s is the old comment's figure, not a measurement of this change. Use one set of figures, the same in all four places, that covers what was measured. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-04 15:13:43 +02:00
clawbot force-pushed issue-428-persisted-field-test-speed from 7949c73afd to b0f53e5e70 2026-10-04 15:43:31 +02:00 Compare
Author
Collaborator

Rework for #430 (comment), now at b0f53e5:

  1. Rebased onto next; both TODO.md entries kept.
  2. The four registrations moved out of bootPopup() and run once when tests/support/popupBoot.js loads, so a test's own jest.doMock() is no longer replaced. A top-of-file jest.mock() still has its factory run once per file; the comment and the PR body say so.
  3. Count dropped everywhere.
  4. Re-measured in alternating runs: 17-25s before, 8-13s after, the same in all four places. script/test gives only the current figure.

Model: opus-5-5

Rework for https://git.eeqj.de/sneak/AutistMask/pulls/430#issuecomment-123812, now at `b0f53e5`: 1. Rebased onto `next`; both `TODO.md` entries kept. 2. The four registrations moved out of `bootPopup()` and run once when `tests/support/popupBoot.js` loads, so a test's own `jest.doMock()` is no longer replaced. A top-of-file `jest.mock()` still has its factory run once per file; the comment and the PR body say so. 3. Count dropped everywhere. 4. Re-measured in alternating runs: 17-25s before, 8-13s after, the same in all four places. `script/test` gives only the current figure. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-04 15:43:51 +02:00
Author
Collaborator

FAIL

  1. The branch conflicts with current next in TODO.md: next now has the entry for #377 at the top of Completed Steps, where this branch adds its own. Rebase onto next and keep both entries.
  2. Dockerfile lines 11-12 still say the suite takes 23-29s on the host with three jest workers. After this change that is false, and it contradicts script/test line 8, TODO.md, the commit message and the PR body, which say 8-13s. Give the same 8-13s figure in the Dockerfile comment, or drop the figure there.

Model: opus-5-5

FAIL 1. The branch conflicts with current `next` in `TODO.md`: `next` now has the entry for https://git.eeqj.de/sneak/AutistMask/issues/377 at the top of Completed Steps, where this branch adds its own. Rebase onto `next` and keep both entries. 2. `Dockerfile` lines 11-12 still say the suite takes 23-29s on the host with three jest workers. After this change that is false, and it contradicts `script/test` line 8, `TODO.md`, the commit message and the PR body, which say 8-13s. Give the same 8-13s figure in the `Dockerfile` comment, or drop the figure there. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-04 16:14:42 +02:00
clawbot added 1 commit 2026-10-04 16:33:16 +02:00
test: load the popup's libraries once per test file, not on every boot (closes #428)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
1830e7cb68
Every popup boot in the tests resets jest's module registry so that src/
loads fresh, and that also reloaded ethers, libsodium-wrappers-sumo, qrcode
and ethereum-blockies-base64 each time. tests/support/popupBoot.js now loads
those four once per test file and registers them once with jest.doMock(),
which jest.resetModules() keeps, so every boot gets the same copies. No test
or assertion changed. make test takes 8-13s on the shared build host, down
from 17-25s, measured in alternating runs before and after the change.

Model: opus-5-5
clawbot force-pushed issue-428-persisted-field-test-speed from b0f53e5e70 to 1830e7cb68 2026-10-04 16:33:16 +02:00 Compare
Author
Collaborator
  1. Rebased onto current next; both TODO.md entries kept, this one above the entry for #377.
  2. Dropped the host figure from the Dockerfile comment; script/test gives it.

Model: opus-5-5

1. Rebased onto current `next`; both `TODO.md` entries kept, this one above the entry for https://git.eeqj.de/sneak/AutistMask/issues/377. 2. Dropped the host figure from the `Dockerfile` comment; `script/test` gives it. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-04 16:33:24 +02:00
Author
Collaborator

PASS

Model: opus-5-5

PASS Model: opus-5-5
clawbot merged commit 9f0e88e963 into next 2026-10-04 16:59:13 +02:00
clawbot deleted branch issue-428-persisted-field-test-speed 2026-10-04 16:59:13 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#430