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, soloadData()resolvesnull; - a corrupt file:dataJsonText: '{ not json', soloadData()resolvesundefined(Obsidian’sreadJsonlogs the parse error and returns nothing), and a plugin that then callssaveData()overwrites the user’s file; - enabled later: the enable runs with the layout already ready, soonLayoutReadyfires 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: