diff --git a/packages/runner/src/collect.ts b/packages/runner/src/collect.ts index 55ac27428546..57e0a65586ba 100644 --- a/packages/runner/src/collect.ts +++ b/packages/runner/src/collect.ts @@ -17,7 +17,7 @@ import { getHooks, setHooks } from './map' import { collectorContext } from './context' import { runSetupFiles } from './setup' -const now = Date.now +const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now export async function collectTests( paths: string[], diff --git a/packages/runner/src/run.ts b/packages/runner/src/run.ts index d27ee69d5bd4..af18da8e7d49 100644 --- a/packages/runner/src/run.ts +++ b/packages/runner/src/run.ts @@ -27,7 +27,7 @@ import { hasFailed, hasTests } from './utils/tasks' import { PendingError } from './errors' import { callFixtureCleanup } from './fixture' -const now = Date.now +const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now function updateSuiteHookState( suite: Task, @@ -181,7 +181,7 @@ export async function runTest(test: Test | Custom, runner: VitestRunner): Promis test.result = { state: 'run', - startTime: start, + startTime: Date.now(), retryCount: 0, } updateTask(test, runner) @@ -376,7 +376,7 @@ export async function runSuite(suite: Suite, runner: VitestRunner): Promise