Skip to content
Tauri

mockWindows

mockWindows(current, …_additionalWindows): void

Defined in: mocks.ts:248

Mocks one or many window labels. In non-tauri context it is required to call this function before using the @tauri-apps/api/window module.

This function only mocks the presence of windows, window properties (e.g. width and height) can be mocked like regular IPC calls using the mockIPC function.

import { mockWindows } from "@tauri-apps/api/mocks";
import { getCurrentWindow } from "@tauri-apps/api/window";
mockWindows("main", "second", "third");
const win = getCurrentWindow();
win.label // "main"
import { mockWindows } from "@tauri-apps/api/mocks";
mockWindows("main", "second", "third");
mockIPC((cmd, args) => {
if (cmd === "plugin:event|emit") {
console.log('emit event', args?.event, args?.payload);
}
});
const { emit } = await import("@tauri-apps/api/event");
await emit('loaded'); // this will cause the mocked IPC handler to log to the console.

string

Label of window this JavaScript context is running in.

string[]

void

1.0.0


© 2025 Tauri Contributors. CC-BY / MIT