Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 3, 2023
1 parent 3b5a795 commit 35ee16e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions src/nuxt-vitest/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ export async function getVitestConfigFromNuxt(
): Promise<InlineConfig & { test: VitestConfig }> {
if (!options) options = await startNuxtAndGetViteConfig()
options.viteConfig.plugins = options.viteConfig.plugins || []
options.viteConfig.plugins = options.viteConfig.plugins.filter(p => (p as any)?.name !== 'nuxt:import-protection')
options.viteConfig.plugins = options.viteConfig.plugins.filter(
p => (p as any)?.name !== 'nuxt:import-protection'
)

for (const name in vuePlugins) {
if (!options.viteConfig.plugins?.some(p => (p as any)?.name === name)) {
const [plugin, key] = vuePlugins[name as keyof typeof vuePlugins]
// @ts-expect-error mismatching component options
options.viteConfig.plugins.unshift(plugin((options.viteConfig as ViteConfig)[key]))
options.viteConfig.plugins.unshift(
plugin((options.viteConfig as ViteConfig)[key])
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vitest-environment-nuxt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default <Environment>{
config: {
public: {},
app: { baseURL: '/' },
...environmentOptions?.nuxtRuntimeConfig
...environmentOptions?.nuxtRuntimeConfig,
},
data: {},
state: {},
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/nuxt-vitest/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineNuxtConfig({
logToConsole: true,
},
imports: {
injectAtEnd: true
injectAtEnd: true,
},
vite: {
// TODO: fix bug with stubbing root package
Expand All @@ -29,5 +29,5 @@ export default defineNuxtConfig({
public: {
hello: 'world',
},
}
},
})
8 changes: 4 additions & 4 deletions test/fixtures/nuxt-vitest/tests/nuxt/config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { it, expect } from 'vitest'

it('should return the runtimeConfig from nuxt.config', () => {
const config = useRuntimeConfig();
expect(config).toBeTypeOf('object');
const config = useRuntimeConfig()
expect(config).toBeTypeOf('object')
expect(config?.public).toEqual({
hello: 'world'
hello: 'world',
})
})
})

0 comments on commit 35ee16e

Please sign in to comment.