Skip to content

Commit

Permalink
fix: check config.server.hmr instead of env to detect testing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Jun 7, 2023
1 parent a651c85 commit a3c06b0
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
skipFastRefresh =
isProduction ||
config.command === 'build' ||
(!!process.env.TEST && !process.env.VITE_TEST_HMR)
config.server.hmr === false

if ('jsxPure' in opts) {
config.logger.warnOnce(
Expand Down
2 changes: 1 addition & 1 deletion playground/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export async function untilUpdated(
runInBuild = false,
): Promise<void> {
if (isBuild && !runInBuild) return
const maxTries = process.env.CI ? 200 : 50
const maxTries = process.env.CI ? 100 : 50
for (let tries = 0; tries < maxTries; tries++) {
const actual = (await poll()) ?? ''
if (actual.indexOf(expected) > -1 || tries === maxTries - 1) {
Expand Down
2 changes: 1 addition & 1 deletion playground/vitest.config.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from 'node:path'
import { defineConfig } from 'vitest/config'

const timeout = process.env.CI ? 50000 : 30000
const timeout = process.env.CI ? 20_000 : 10_000

export default defineConfig({
resolve: {
Expand Down
1 change: 0 additions & 1 deletion playground/vitestGlobalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const DIR = path.join(os.tmpdir(), 'vitest_playwright_global_setup')
let browserServer: BrowserServer | undefined

export async function setup(): Promise<void> {
process.env.VITE_TEST_HMR = 'true' // To force HMR transformation in test environment
process.env.NODE_ENV = process.env.VITE_TEST_BUILD
? 'production'
: 'development'
Expand Down

0 comments on commit a3c06b0

Please sign in to comment.