Skip to content

prepareFuzzySearch

Builds a fuzzy search callback for a query. The mock’s own scoring matches the query’s characters in order, ignoring case, and rewards consecutive matches and matches at word boundaries; its scores are not Obsidian’s.

Import:

import { prepareFuzzySearch } from 'obsidian-test-mocks/obsidian';

Signature:

function prepareFuzzySearch(query: string): (text: string) => SearchResult | null

Parameters:

Parameter Type Description
query string The fuzzy query.

Returns: (text: string) => SearchResult | null — A callback that searches a text, returning the matched ranges and a score (negative, lower for better matches), or null when not every query character is found in order.