Skip to content

Commit caf4d82

Browse files
committedNov 20, 2023
style: lint
1 parent 326aaef commit caf4d82

File tree

4 files changed

+47
-26
lines changed

4 files changed

+47
-26
lines changed
 

‎src/nuxt-vitest/config.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ export async function getVitestConfigFromNuxt(
121121
},
122122
},
123123
nuxtRuntimeConfig: options.nuxt.options.runtimeConfig,
124-
nuxtRouteRules: defu({}, options.nuxt.options.routeRules, options.nuxt.options.nitro?.routeRules)
124+
nuxtRouteRules: defu(
125+
{},
126+
options.nuxt.options.routeRules,
127+
options.nuxt.options.nitro?.routeRules
128+
),
125129
},
126130
environmentMatchGlobs: [
127131
['**/*.nuxt.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}', 'nuxt'],

‎src/vitest-environment-nuxt/index.ts

+35-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import { createFetch } from 'ofetch'
33
import { indexedDB } from 'fake-indexeddb'
44
import { joinURL } from 'ufo'
55
import { createApp, defineEventHandler, toNodeListener } from 'h3'
6-
import { createRouter as createRadixRouter, exportMatcher, toRouteMatcher } from 'radix3'
6+
import {
7+
createRouter as createRadixRouter,
8+
exportMatcher,
9+
toRouteMatcher,
10+
} from 'radix3'
711
import { populateGlobal } from 'vitest/environments'
812
import {
913
createCall,
@@ -108,25 +112,38 @@ export default <Environment>{
108112
createRadixRouter({ routes: environmentOptions.nuxtRouteRules || {} })
109113
)
110114
const matcher = exportMatcher(routeRulesMatcher)
111-
const manifestOutputPath = joinURL('/', environmentOptions?.nuxtRuntimeConfig.app?.buildAssetsDir || '_nuxt', 'builds')
115+
const manifestOutputPath = joinURL(
116+
'/',
117+
environmentOptions?.nuxtRuntimeConfig.app?.buildAssetsDir || '_nuxt',
118+
'builds'
119+
)
112120
const manifestBaseRoutePath = joinURL('/_', manifestOutputPath)
113121

114-
h3App.use(`${manifestBaseRoutePath}/latest.json`, defineEventHandler(() => ({
115-
id: 'test',
116-
timestamp
117-
})))
118-
h3App.use(`${manifestBaseRoutePath}/meta/test.json`, defineEventHandler(() => ({
119-
id: 'test',
120-
timestamp,
121-
matcher,
122-
prerendered: []
123-
})))
124-
h3App.use(`${manifestBaseRoutePath}/meta/dev.json`, defineEventHandler(() => ({
125-
id: 'test',
126-
timestamp,
127-
matcher,
128-
prerendered: []
129-
})))
122+
h3App.use(
123+
`${manifestBaseRoutePath}/latest.json`,
124+
defineEventHandler(() => ({
125+
id: 'test',
126+
timestamp,
127+
}))
128+
)
129+
h3App.use(
130+
`${manifestBaseRoutePath}/meta/test.json`,
131+
defineEventHandler(() => ({
132+
id: 'test',
133+
timestamp,
134+
matcher,
135+
prerendered: [],
136+
}))
137+
)
138+
h3App.use(
139+
`${manifestBaseRoutePath}/meta/dev.json`,
140+
defineEventHandler(() => ({
141+
id: 'test',
142+
timestamp,
143+
matcher,
144+
prerendered: [],
145+
}))
146+
)
130147

131148
registry.add(`${manifestOutputPath}/latest.json`)
132149
registry.add(`${manifestOutputPath}/meta/test.json`)

‎src/vitest-environment-nuxt/runtime/mount.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ export async function mountSuspended<T>(
8585
...component,
8686
render: render
8787
? (_ctx: any, ...args: any[]) => {
88-
// add all _ctx properties to renderContext
89-
// the renderContext must remain intact, otherwise the emits don't work
90-
for (const key in _ctx) {
91-
renderContext[key] = _ctx[key]
88+
// add all _ctx properties to renderContext
89+
// the renderContext must remain intact, otherwise the emits don't work
90+
for (const key in _ctx) {
91+
renderContext[key] = _ctx[key]
92+
}
93+
return render.apply(_ctx, [renderContext, ...args])
9294
}
93-
return render.apply(_ctx, [renderContext, ...args])
94-
}
9595
: undefined,
9696
setup: setup
9797
? (props: Record<string, any>) =>

‎test/fixtures/nuxt-vitest/tests/nuxt/export-define-component.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ it('should support export default that returns render function', async () => {
5555
<h1>ExportDefaultReturnsRenderComponent</h1><pre>Hello nuxt-vitest</pre><pre>XHello nuxt-vitest</pre>
5656
</div>"
5757
`)
58-
})
58+
})

0 commit comments

Comments
 (0)
Please sign in to comment.