Skip to content

Commit 8a8d3f0

Browse files
authoredOct 2, 2024··
fix(vitest): make env.SSR consistent between different pools (#6616)
1 parent ed8b7c0 commit 8a8d3f0

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed
 

‎packages/vitest/src/runtime/runVmTests.ts

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ export async function run(
4545
KNOWN_ASSET_TYPES.forEach((type) => {
4646
_require.extensions[`.${type}`] = resolveAsset
4747
})
48+
process.env.SSR = ''
49+
}
50+
else {
51+
process.env.SSR = '1'
4852
}
4953

5054
// @ts-expect-error not typed global for patched timers

‎test/core/test/environments/jsdom.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,7 @@ test('jsdom global is exposed', () => {
101101
dom.reconfigure({ url: 'https://examples.new.com' })
102102
expect(location.href).toBe('https://examples.new.com/')
103103
})
104+
105+
test('ssr is disabled', () => {
106+
expect(import.meta.env.SSR).toBe(false)
107+
})

‎test/core/test/environments/node.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ test.runIf(nodeMajor > 16)('url correctly creates an object', () => {
99
URL.createObjectURL(new Blob([]))
1010
}).not.toThrow()
1111
})
12+
13+
test('ssr is enabled', () => {
14+
expect(import.meta.env.SSR).toBe(true)
15+
})

‎test/core/vitest.workspace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Pool } from 'vitest'
1+
import type { Pool } from 'vitest/node'
22
import { defineWorkspace } from 'vitest/config'
33

44
function project(pool: Pool) {

0 commit comments

Comments
 (0)
Please sign in to comment.