#3564·emdash

Flaky admin browser test: wxr-import.test.ts fails with "vi.mocked(...).mockReset is not a function"

Author: swisskyCreated Sep 28, 2026Updated Sep 28, 2026
Labelsbot:reprobot:reproduced

Description

The admin browser test packages/admin/tests/lib/wxr-import.test.ts, "executeWxrImport › drives every phase and aggregates content, taxonomy, and section results", fails intermittently in the Browser Tests job:

FAIL  chromium  tests/lib/wxr-import.test.ts > executeWxrImport > drives every phase and aggregates content, taxonomy, and section results
TypeError: vi.mocked(...).mockReset is not a function

Seen in Browser Tests on #3548, which doesn't touch the admin package. A rerun of the same commit passed, and the file passes locally (npx vitest run tests/lib/wxr-import.test.ts in packages/admin).

What the error means

The failure is in beforeEach, before the test body runs:

typescript
vi.mock("../../src/lib/api/client.js", async (importOriginal) => {
	const actual = await importOriginal<typeof import("../../src/lib/api/client.js")>();
	return { ...actual, apiFetch: vi.fn() };
});

import { apiFetch } from "../../src/lib/api/client.js";
// ...
beforeEach(() => {
	vi.mocked(apiFetch).mockReset();
});

mockReset is not a function means apiFetch was the real function, not the vi.fn() from the factory. So in the failing run the module mock wasn't in place when the file imported client.js. I haven't found why it only happens sometimes in browser mode; around ten other admin test files mock the same module and don't show this.

Not a regression from the PR it was observed on

The test was added on Sept 27 in #3439. The PR where it failed changes only packages/registry-loader and apps/plugins-site.