chore(deps): update vitest monorepo to v5 #345

Merged
argoyle merged 2 commits from renovate/major-vitest-monorepo into main 2026-09-10 20:04:38 +00:00
2 changed files with 20 additions and 9 deletions
Showing only changes of commit 83576657f4 - Show all commits

No files matched your search

@@ -14,20 +14,23 @@ const mockOrganizations = [
// For now, the component is indirectly tested through useOrganizationSelector tests // For now, the component is indirectly tested through useOrganizationSelector tests
// and manual testing shows it works correctly // and manual testing shows it works correctly
describe('OrganizationSwitcher - Single Organization', () => { // vi.mock is hoisted above the imports and the factory runs once, on the first
beforeEach(() => { // import of the mocked module -- it was never re-applied per test despite sitting
vi.resetModules() // in beforeEach. vitest 5 rejects the nested call outright rather than silently
mockSelectOrganization.mockClear() // hoisting it, so declare it where it actually executes.
vi.mock('~/composables/useOrganizationSelector', () => ({
// Mock with single organization
vi.mock('~/composables/useOrganizationSelector', () => ({
useOrganizationSelector: () => ({ useOrganizationSelector: () => ({
organizations: ref([mockOrganizations[0]]), organizations: ref([mockOrganizations[0]]),
selectedOrganization: ref(mockOrganizations[0]), selectedOrganization: ref(mockOrganizations[0]),
selectedOrgId: ref('1'), selectedOrgId: ref('1'),
selectOrganization: mockSelectOrganization, selectOrganization: mockSelectOrganization,
}), }),
})) }))
describe('OrganizationSwitcher - Single Organization', () => {
beforeEach(() => {
vi.resetModules()
mockSelectOrganization.mockClear()
}) })
it('should show a chip for single organization', async () => { it('should show a chip for single organization', async () => {
+9 -1
View File
@@ -31,7 +31,15 @@ class LocalStorageMock {
} }
} }
global.localStorage = new LocalStorageMock() as unknown as Storage // jsdom defines localStorage as a getter-only accessor on the window object, so a
// plain assignment throws ("Cannot set property localStorage ... which has only a
// getter") under vitest 5, which no longer shadows it with a writable global.
// defineProperty replaces the accessor outright and works on both.
Object.defineProperty(globalThis, 'localStorage', {
value: new LocalStorageMock() as unknown as Storage,
writable: true,
configurable: true,
})
// Make Vue composables globally available // Make Vue composables globally available
global.ref = Vue.ref global.ref = Vue.ref