~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
/**
* Global test setup for Vitest + happy-dom
*
* Stubs browser globals that the app code expects to exist
* (e.g. SafeLogger, which is loaded as a <script> tag in production).
*/
// Minimal SafeLogger stub — tests can spy on these via vi.spyOn()
globalThis.SafeLogger = {
log: () => {},
warn: () => {},
error: () => {},
info: () => {},
debug: () => {},
};
// Match production's standards-mode document so KaTeX does not warn about
// happy-dom's default doctype-less (quirks-mode) test document.
if (!document.doctype) {
const doctype = document.implementation.createDocumentType('html', '', '');
document.insertBefore(doctype, document.documentElement);
}
// happy-dom does not currently derive compatMode from an inserted doctype.
if (document.compatMode !== 'CSS1Compat') {
Object.defineProperty(document, 'compatMode', {
value: 'CSS1Compat',
configurable: true,
});
}
// Load the shared formatting service (window.formatting) — in production
// base.html always loads services/formatting.js before any page/component
// script, and several of them now delegate to it (e.g.
// window.formatting.stripMarkdownToText for note-card previews). Loading it
// here mirrors that load order for every test in ONE place instead of each
// notes test re-importing it. Tests that need a partial stub still reassign
// window.formatting in their own beforeAll (that override wins for them).
// Imported after the SafeLogger stub since formatting code may reference it.
import '@js/services/formatting.js';
// Shared notes helpers (window.NotesShared.postJson/csrfToken/toast) — in
// production every notes page/component loads components/notes_shared.js
// via its own <script defer> tag before the consumers that delegate to it.
// Load it here so those consumers resolve in tests. Only defines functions
// at import (no safeFetch/DOM calls), so import order is not sensitive.
import '@js/components/notes_shared.js';
// Shared semantic-search helpers + tuning constants
// (window.SemanticSearch.buildTieredResults / flattenTieredResults /
// MIN_SIMILARITY / MIN_QUERY_LENGTH). The notes and unified-search pages
// read these; production loads semantic_search.js before them. Tests that
// need a custom buildTieredResults still reassign window.SemanticSearch.
import '@js/components/semantic_search.js';
// The base template loads the action registry before every page script.
// Unit fixtures have no response authorization; binding behavior is exercised
// separately with explicit per-document tokens in template-events.test.js.
import '@js/security/template-events.js';
// Shared byte-size formatter (window.formatBytes) — in production,
// collection_details.js and delete_manager.js are emitted from
// {% block content %}, which base.html renders BEFORE its own shared
// deferred scripts, including utils/format-bytes.js (~line 286); see
// tests/web/test_template_script_placement.py for the documented
// ordering model. That's not a problem: both consumers only call
// window.formatBytes from inside event handlers, after the document (and
// every deferred script) has finished loading, never at their own
// top-level script-evaluation time — so every page has it available by
// the time handlers run, regardless of script order. Load it here so
// every test gets that same guarantee instead of each consumer's test
// file importing it individually.
import '@js/utils/format-bytes.js';
// Auth-aware fetch wrapper (security/safe-fetch.js). In production it wraps
// safeFetch and redirects to /auth/login on a 401; page/component scripts call
// it instead of safeFetch. In tests we delegate to whatever safeFetch mock the
// current test installed, read lazily so it a) is always defined and b) keeps
// assertions on safeFetch.mock.calls valid (the call still reaches safeFetch).
// A test that needs to exercise the 401-redirect path overrides this global.
globalThis.safeFetchWithAuth = (...args) => globalThis.safeFetch(...args);