oxynote/web/vitest.nuxt-setup.ts
dependabot[bot] f5913393aa
deps(web): bump the breaking group across 1 directory with 4 updates (#110)
* deps(web): bump the breaking group across 1 directory with 4 updates

Bumps the breaking group with 4 updates in the /web directory: [@vitest/browser](https://github.com/vitest-dev/vitest/tree/HEAD/packages/browser), [@vitest/browser-playwright](https://github.com/vitest-dev/vitest/tree/HEAD/packages/browser-playwright), [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) and [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest).


Updates `@vitest/browser` from 4.1.11 to 5.0.0
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v5.0.0/packages/browser)

Updates `@vitest/browser-playwright` from 4.1.11 to 5.0.0
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v5.0.0/packages/browser-playwright)

Updates `@vitest/coverage-v8` from 4.1.11 to 5.0.0
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v5.0.0/packages/coverage-v8)

Updates `vitest` from 4.1.11 to 5.0.0
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v5.0.0/packages/vitest)

---
updated-dependencies:
- dependency-name: "@vitest/browser"
  dependency-version: 5.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: breaking
- dependency-name: "@vitest/browser-playwright"
  dependency-version: 5.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: breaking
- dependency-name: "@vitest/coverage-v8"
  dependency-version: 5.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: breaking
- dependency-name: vitest
  dependency-version: 5.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: breaking
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix vitest config in web

* fix tests

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: swithek <52840391+swithek@users.noreply.github.com>
2026-09-12 15:29:55 +03:00

47 lines
2.1 KiB
TypeScript

import { registerEndpoint } from "@nuxt/test-utils/runtime"
// the nuxt project points @nuxt/icon at no provider, so every icon that is
// not already in the client bundle fails its load and warns once per
// render. The load is asynchronous and the warning often lands after the
// test has finished, and vitest 5 turns a console message caught while the
// worker is tearing down into an unhandled EnvironmentTeardownError. The
// warning is dropped here, before vitest's console interception forwards
// it, rather than in the main process's onConsoleLog, which runs too late
// to stop the forwarding.
const warn = console.warn
console.warn = (...args: unknown[]) => {
if (
typeof args[0] === "string" &&
args[0].startsWith("[Icon] failed to load icon")
) {
return
}
warn(...args)
}
// mounting anything inside the nuxt runtime boots a router, and the global
// middleware in app/middleware/01.redirect.global.ts asks better-auth for
// the current session before every navigation. Unstubbed that is a real
// request to the (nonexistent) test host, costing ~5s per mount before it
// gives up — so the nuxt project stubs a signed-out session for every
// suite. Suites that need a session register the same url again: the
// endpoint registry resolves the most recently registered handler first.
//
// It takes both spellings of the url, for two different reasons.
// @nuxt/test-utils only diverts a request away from the real network when
// the string the client asked for is in its registry, and better-auth asks
// for the absolute url its client was built with — so the absolute entry is
// what keeps the request off the network. The diverted request then reaches
// the test-time h3 app with the origin stripped, so the handler that
// actually answers it is the one filed under the bare path. With only the
// absolute entry the call 404s; with only the path entry it goes to the
// network and stalls.
registerEndpoint("http://test.local/auth-realtime/api/auth/get-session", () => {
return null
})
registerEndpoint("/auth-realtime/api/auth/get-session", () => {
return null
})