Tauri Core API - v2.6.0
    Preparing search index...

    Function mockWindows

    • 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.

      Examples

      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.

      Parameters

      • current: string

        Label of window this JavaScript context is running in.

      • ..._additionalWindows: string[]

      Returns void

      1.0.0