test: load the popup's libraries once per test file, not on every boot #430
+5
-6
@@ -8,12 +8,11 @@ WORKDIR /app
|
|||||||
# image sets it.
|
# image sets it.
|
||||||
ENV AUTISTMASK_LINT_NATIVE=1
|
ENV AUTISTMASK_LINT_NATIVE=1
|
||||||
|
|
||||||
# script/test's default 30s bound is the host figure, against a suite that
|
# script/test's default 30s bound is the host figure. In here the same suite
|
||||||
# takes 23-29s there with three jest workers. In here the same suite starts on
|
# starts on a cold jest cache and shares the runner with the rest of the build,
|
||||||
# a cold jest cache and shares the runner with the rest of the build, so 30s
|
# so 30s is too tight — it killed a healthy suite at 30.6s on a cold CI cache.
|
||||||
# is too tight — it killed a healthy suite at 30.6s on a cold CI cache. 180s
|
# 180s still catches a hang in three minutes and cannot be tripped by a suite
|
||||||
# still catches a hang in three minutes and cannot be tripped by a suite that
|
# that is merely running on contended hardware.
|
||||||
# is merely running on contended hardware.
|
|
||||||
ENV AUTISTMASK_TEST_TIMEOUT=180
|
ENV AUTISTMASK_TEST_TIMEOUT=180
|
||||||
|
|
||||||
# script/bootstrap installs all prerequisites (make via apt here; node
|
# script/bootstrap installs all prerequisites (make via apt here; node
|
||||||
|
|||||||
@@ -45,6 +45,15 @@ but the review is broader than any of them.
|
|||||||
|
|
||||||
# Completed Steps
|
# Completed Steps
|
||||||
|
|
||||||
|
- 2026-10-04: `make test` takes 8-13s on the shared build host, down from
|
||||||
|
17-25s, measured in alternating runs before and after the change
|
||||||
|
([#428](https://git.eeqj.de/sneak/AutistMask/issues/428)). Each popup boot in
|
||||||
|
the tests (`tests/support/popupBoot.js`) resets jest's module registry so that
|
||||||
|
everything under `src/` loads fresh, and that also reloaded `ethers`,
|
||||||
|
`libsodium-wrappers-sumo`, `qrcode` and `ethereum-blockies-base64` every time.
|
||||||
|
Those four libraries are now loaded once per test file and handed to every
|
||||||
|
boot. No test or assertion changed.
|
||||||
|
|
||||||
- 2026-10-04: A token whose scale is unknown reads the same on the Send screen
|
- 2026-10-04: A token whose scale is unknown reads the same on the Send screen
|
||||||
as on the confirmation screen
|
as on the confirmation screen
|
||||||
([#377](https://git.eeqj.de/sneak/AutistMask/issues/377)). When two addresses'
|
([#377](https://git.eeqj.de/sneak/AutistMask/issues/377)). When two addresses'
|
||||||
|
|||||||
+6
-6
@@ -5,12 +5,12 @@
|
|||||||
# many-core shared host one per core took gigabytes of RAM per run.
|
# many-core shared host one per core took gigabytes of RAM per run.
|
||||||
#
|
#
|
||||||
# The timeout bounds a hung suite; it is not a performance budget. On the busy
|
# The timeout bounds a hung suite; it is not a performance budget. On the busy
|
||||||
# shared build host the suite takes 23-29s with three workers, so
|
# shared build host the suite takes 8-13s with three workers, inside
|
||||||
# REPO_POLICIES' 30s cap is tight there, not comfortable. Inside the image the
|
# REPO_POLICIES' 20s budget. Inside the image the same suite also pays a cold
|
||||||
# same suite also pays a cold jest cache and shares the runner with the rest of
|
# jest cache and shares the runner with the rest of the build, which is not what
|
||||||
# the build, which is not what that budget describes, so the Dockerfile raises
|
# that budget describes, so the Dockerfile raises the bound through
|
||||||
# the bound through AUTISTMASK_TEST_TIMEOUT. A cap a healthy suite can trip on a
|
# AUTISTMASK_TEST_TIMEOUT. A cap a healthy suite can trip on a cold cache
|
||||||
# cold cache produces a red that means nothing, and teaches "just run it again".
|
# produces a red that means nothing, and teaches "just run it again".
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||||
|
|||||||
@@ -20,6 +20,26 @@ const path = require("path");
|
|||||||
|
|
||||||
const { makeStorageStub } = require("./storageStub");
|
const { makeStorageStub } = require("./storageStub");
|
||||||
|
|
||||||
|
// The four libraries the popup loads from node_modules, loaded once per test
|
||||||
|
// file and handed to every boot. jest.resetModules() in bootPopup() empties the
|
||||||
|
// module cache but keeps what jest.doMock() registered, so these registrations
|
||||||
|
// hold for every boot in the file and the libraries are not loaded again. None
|
||||||
|
// of them holds popup state; everything under src/ is still loaded fresh on
|
||||||
|
// each boot.
|
||||||
|
//
|
||||||
|
// A test's own mock of one of them: a jest.doMock() made inside the test
|
||||||
|
// replaces the registration here, as it would for any module. A top-of-file
|
||||||
|
// jest.mock() is what the require() below gets, so it is kept, but its factory
|
||||||
|
// runs once per file and every boot shares the same mock object.
|
||||||
|
const ethers = require("ethers");
|
||||||
|
const sodium = require("libsodium-wrappers-sumo");
|
||||||
|
const QRCode = require("qrcode");
|
||||||
|
const makeBlockie = require("ethereum-blockies-base64");
|
||||||
|
jest.doMock("ethers", () => ethers);
|
||||||
|
jest.doMock("libsodium-wrappers-sumo", () => sodium);
|
||||||
|
jest.doMock("qrcode", () => QRCode);
|
||||||
|
jest.doMock("ethereum-blockies-base64", () => makeBlockie);
|
||||||
|
|
||||||
const POPUP_HTML = fs.readFileSync(
|
const POPUP_HTML = fs.readFileSync(
|
||||||
path.join(__dirname, "..", "..", "src", "popup", "index.html"),
|
path.join(__dirname, "..", "..", "src", "popup", "index.html"),
|
||||||
"utf8",
|
"utf8",
|
||||||
|
|||||||
Reference in New Issue
Block a user