Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/browser/src/client/tester/tester-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ export class CommandsManager {
}
}

const now = Date.now
const now = globalThis.performance
? globalThis.performance.now.bind(globalThis.performance)
: Date.now

export function processTimeoutOptions<T extends { timeout?: number }>(options_: T | undefined): T | undefined {
if (
Expand All @@ -212,7 +214,7 @@ export function processTimeoutOptions<T extends { timeout?: number }>(options_:
options_ = options_ || {} as T
const currentTime = now()
const endTime = startTime + timeout
const remainingTime = endTime - currentTime
const remainingTime = Math.floor(endTime - currentTime)
if (remainingTime <= 0) {
return options_
}
Expand Down
4 changes: 3 additions & 1 deletion packages/runner/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import { PendingError } from './errors'
import { finishSendTasksUpdate } from './run'
import { getRunner } from './suite'

const now = Date.now
const now = globalThis.performance
? globalThis.performance.now.bind(globalThis.performance)
: Date.now

export const collectorContext: RuntimeContext = {
tasks: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
UserConfig,
} from './node/types/config'
import os from 'node:os'
import { isCI } from './utils/env'
import { isAgent, isCI } from './utils/env'

export { defaultBrowserPort } from './constants'

Expand Down Expand Up @@ -93,7 +93,7 @@ export const configDefaults: Readonly<{
}> = Object.freeze({
allowOnly: !isCI,
isolate: true,
watch: !isCI && process.stdin.isTTY,
watch: !isCI && process.stdin.isTTY && !isAgent,
globals: false,
environment: 'node' as const,
clearMocks: false,
Expand Down
2 changes: 1 addition & 1 deletion test/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ Some test suites don't support running it remotely (`fixtures/inspect` and `fixt
pnpm docker up -d

# Run tests with BROWSER_WS_ENDPOINT
BROWSER_WS_ENDPOINT=ws://127.0.0.1:6677/ pnpm run test:playwright
BROWSER_WS_ENDPOINT=true pnpm run test:playwright
```
6 changes: 4 additions & 2 deletions test/browser/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { webdriverio } from '@vitest/browser-webdriverio'

const providerName = (process.env.PROVIDER || 'playwright') as 'playwright' | 'webdriverio' | 'preview'

const wsEndpoint = process.env.BROWSER_WS_ENDPOINT === 'true' ? 'ws://127.0.0.1:6677/' : process.env.BROWSER_WS_ENDPOINT

export const providers = {
playwright: (options?: Parameters<typeof playwright>[0]) => playwright(process.env.BROWSER_WS_ENDPOINT
playwright: (options?: Parameters<typeof playwright>[0]) => playwright(wsEndpoint
? {
...options,
connectOptions: {
wsEndpoint: process.env.BROWSER_WS_ENDPOINT,
wsEndpoint,
exposeNetwork: '<loopback>',
},
}
Expand Down
Loading