Skip to content

Commit 1c62206

Browse files
committed
fix: default to npm when testing
1 parent e68e2b6 commit 1c62206

File tree

3 files changed

+2
-15
lines changed

3 files changed

+2
-15
lines changed

app/composables/useSettings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const DEFAULT_SETTINGS: AppSettings = {
4141
hidePlatformPackages: true,
4242
selectedLocale: null,
4343
preferredBackgroundTheme: null,
44-
searchProvider: 'algolia',
44+
searchProvider: import.meta.test ? 'npm' : 'algolia',
4545
sidebar: {
4646
collapsed: [],
4747
},

test/nuxt/components/compare/PackageSelector.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest'
2-
import { nextTick, ref } from 'vue'
2+
import { ref } from 'vue'
33
import { mountSuspended } from '@nuxt/test-utils/runtime'
44
import PackageSelector from '~/components/Compare/PackageSelector.vue'
55

@@ -141,7 +141,6 @@ describe('PackageSelector', () => {
141141

142142
const input = component.find('input')
143143
await input.setValue('lodash')
144-
await nextTick()
145144
await input.trigger('keydown', { key: 'Enter' })
146145

147146
const emitted = component.emitted('update:modelValue')
@@ -158,7 +157,6 @@ describe('PackageSelector', () => {
158157

159158
const input = component.find('input')
160159
await input.setValue('no dep')
161-
await nextTick()
162160
await input.trigger('keydown', { key: 'Enter' })
163161

164162
const emitted = component.emitted('update:modelValue')
@@ -175,7 +173,6 @@ describe('PackageSelector', () => {
175173

176174
const input = component.find('input')
177175
await input.setValue('lodash')
178-
await nextTick()
179176
await input.trigger('keydown', { key: 'Enter' })
180177

181178
// Input should be cleared

test/nuxt/setup.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,4 @@ if (typeof window !== 'undefined') {
2323
removeColorScheme: () => {},
2424
}
2525
}
26-
27-
// force npm search provider in tests for compatibility with our mocks
28-
const settingsKey = 'npmx-settings'
29-
try {
30-
const existing = JSON.parse(localStorage.getItem(settingsKey) || '{}')
31-
existing.searchProvider = 'npm'
32-
localStorage.setItem(settingsKey, JSON.stringify(existing))
33-
} catch {
34-
localStorage.setItem(settingsKey, JSON.stringify({ searchProvider: 'npm' }))
35-
}
3626
}

0 commit comments

Comments
 (0)