0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-11 03:44:18 +02:00
gitea/web_src/js/vitest.setup.ts
Giteabot a2283a0c03
Clean up and improve non-gitea js error filter (#37148) (#37155)
Backport #37148 by @silverwind

1. Filter out errors that contain `chrome-extension://` etc protocols
2. Extract filtering into its own function and test it
3. Fix the `window.config.assetUrlPrefix` mock, guaranteed to end with
`/assets`
4. Remove useless `??` and `?.` for properties that always exist

---
This PR was written with the help of Claude Opus 4.6

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com>
2026-04-09 14:35:07 +02:00

28 lines
892 B
TypeScript

// Stub APIs not implemented by happy-dom but needed by dependencies
// XPathEvaluator is used by htmx at module evaluation time
// TODO: Remove after https://github.com/capricorn86/happy-dom/pull/2103 is released
if (!globalThis.XPathEvaluator) {
globalThis.XPathEvaluator = class {
createExpression() { return {evaluate: () => ({iterateNext: () => null})} }
} as any;
}
// Dynamic import so polyfills above are applied before htmx evaluates
await import('./globals.ts');
window.config = {
appUrl: 'http://localhost:3000/',
appSubUrl: '',
assetUrlPrefix: '/assets',
sharedWorkerUri: '',
runModeIsProd: true,
customEmojis: {},
pageData: {},
notificationSettings: {MinTimeout: 0, TimeoutStep: 0, MaxTimeout: 0, EventSourceUpdateTime: 0},
enableTimeTracking: true,
mermaidMaxSourceCharacters: 5000,
i18n: {},
};
export {}; // mark as module for top-level await