Skip to content

Commit

Permalink
chore: fix environment
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jul 11, 2023
1 parent 0fc32ed commit 62bcb35
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
2 changes: 2 additions & 0 deletions packages/ui/client/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ declare global {
const toRef: typeof import('vue')['toRef']
const toRefs: typeof import('vue')['toRefs']
const toValue: typeof import('vue')['toValue']
const toggleDark: typeof import('./composables/dark')['toggleDark']
const totalTests: typeof import('./composables/summary')['totalTests']
const triggerRef: typeof import('vue')['triggerRef']
const tryOnBeforeMount: typeof import('@vueuse/core')['tryOnBeforeMount']
const tryOnBeforeUnmount: typeof import('@vueuse/core')['tryOnBeforeUnmount']
Expand Down
7 changes: 4 additions & 3 deletions packages/vitest/src/integrations/env/edge-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type vm from 'node:vm'
import { importModule } from 'local-pkg'
import type { Environment } from '../../types'
import { populateGlobal } from './utils'

export default <Environment>({
export default ({
name: 'edge-runtime',
transformMode: 'ssr',
async setupVM() {
Expand All @@ -16,7 +17,7 @@ export default <Environment>({
})
return {
getVmContext() {
return vm.context
return vm.context as vm.Context
},
teardown() {
// TODO
Expand All @@ -40,4 +41,4 @@ export default <Environment>({
},
}
},
})
}) satisfies Environment
6 changes: 3 additions & 3 deletions packages/vitest/src/integrations/env/happy-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { importModule } from 'local-pkg'
import type { Environment } from '../../types'
import { populateGlobal } from './utils'

export default <Environment>({
export default ({
name: 'happy-dom',
transformMode: 'web',
async setupVm() {
async setupVM() {
const { Window } = await importModule('happy-dom') as typeof import('happy-dom')
const win = new Window()

Expand Down Expand Up @@ -40,4 +40,4 @@ export default <Environment>({
},
}
},
})
}) satisfies Environment
4 changes: 2 additions & 2 deletions packages/vitest/src/integrations/env/jsdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function catchWindowErrors(window: Window) {
}
}

export default <Environment>({
export default ({
name: 'jsdom',
transformMode: 'web',
async setupVM({ jsdom = {} }) {
Expand Down Expand Up @@ -125,4 +125,4 @@ export default <Environment>({
},
}
},
})
}) satisfies Environment
4 changes: 2 additions & 2 deletions packages/vitest/src/integrations/env/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const nodeGlobals = new Map(
}),
)

export default <Environment>({
export default ({
name: 'node',
transformMode: 'ssr',
// this is largely copied from jest's node environment
Expand Down Expand Up @@ -120,4 +120,4 @@ export default <Environment>({
},
}
},
})
}) satisfies Environment
4 changes: 3 additions & 1 deletion packages/vitest/src/runtime/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ export async function run(ctx: WorkerContext) {
const environment = await loadEnvironment(ctx.environment.name, ctx.config.root)

if (!environment.setupVM) {
const envName = ctx.environment.name
const packageId = envName[0] === '.' ? envName : `vitest-environment-${envName}`
throw new TypeError(
`Environment "${ctx.environment.name}" is not a valid environment. `
+ `Package "vitest-environment-${name}" doesn't support vm environment because it doesn't provide "setupVM" method.`,
+ `Path "${packageId}" doesn't support vm environment because it doesn't provide "setupVM" method.`,
)
}

Expand Down
4 changes: 0 additions & 4 deletions test/core/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ export default defineConfig({
setupFiles: [
'./test/setup.ts',
],
// TODO: remove this when PR is done
poolMatchGlobs: [
['**/*', 'experimentalVmThreads'],
],
testNamePattern: '^((?!does not include test that).)*$',
coverage: {
provider: 'istanbul',
Expand Down

0 comments on commit 62bcb35

Please sign in to comment.