Skip to content

reloadPlugin

Disables a plugin, optionally puts its data.json into a given state, and enables it again.

Covers three cases a suite otherwise never reaches, because the setup always enables the plugin once, at startup, with whatever settings it last saved:

  • a fresh install: shouldRemoveDataJson: true, so loadData() resolves null; - a corrupt file: dataJsonText: '{ not json', so loadData() resolves undefined (Obsidian’s readJson logs the parse error and returns nothing), and a plugin that then calls saveData() overwrites the user’s file; - enabled later: the enable runs with the layout already ready, so onLayoutReady fires at once.

The result is returned rather than thrown, because a test of a corrupt data.json asserts on exactly whether the plugin’s onload survived it.

Import:

import { reloadPlugin } from 'obsidian-integration-testing';

Signature:

function reloadPlugin(params: ReloadPluginParams): Promise<ReloadPluginResult>

Parameters:

Parameter Type Description
params ReloadPluginParams The plugin, the data.json state, and transport / vault overrides.

Returns: Promise<ReloadPluginResult> — A Promise resolving to whether the plugin loaded, and the error it raised if not.


Links to this page: