fix(matrix): narrow lazy test module access

This commit is contained in:
Vincent Koc 2026-04-01 23:05:51 +09:00
parent 1d05cbba7a
commit 5a0fd1cffc
1 changed files with 12 additions and 4 deletions

View File

@ -53,6 +53,13 @@ const {
let credentialsReadModule: typeof import("./credentials-read.js") | undefined;
let sdkModule: typeof import("./sdk.js") | undefined;
function requireCredentialsReadModule(): typeof import("./credentials-read.js") {
if (!credentialsReadModule) {
throw new Error("credentials-read test module not initialized");
}
return credentialsReadModule;
}
beforeEach(() => {
installMatrixTestRuntime();
});
@ -597,10 +604,11 @@ describe("resolveMatrixAuth", () => {
});
beforeEach(() => {
vi.mocked(credentialsReadModule.loadMatrixCredentials).mockReset();
vi.mocked(credentialsReadModule.loadMatrixCredentials).mockReturnValue(null);
vi.mocked(credentialsReadModule.credentialsMatchConfig).mockReset();
vi.mocked(credentialsReadModule.credentialsMatchConfig).mockReturnValue(false);
const readModule = requireCredentialsReadModule();
vi.mocked(readModule.loadMatrixCredentials).mockReset();
vi.mocked(readModule.loadMatrixCredentials).mockReturnValue(null);
vi.mocked(readModule.credentialsMatchConfig).mockReset();
vi.mocked(readModule.credentialsMatchConfig).mockReturnValue(false);
saveMatrixCredentialsMock.mockReset();
touchMatrixCredentialsMock.mockReset();
});