mirror of
https://github.com/hanzoai/vitest.git
synced 2026-09-24 17:04:25 +00:00
Co-authored-by: Hiroshi Ogawa <[email protected]> Co-authored-by: OpenCode (claude-opus-4-8) <[email protected]>
32 lines
1.3 KiB
Diff
32 lines
1.3 KiB
Diff
diff --git a/src/fake-timers-src.js b/src/fake-timers-src.js
|
|
index 241a7ad3eeb8b5eb691439fab31a87ef13c76345..2df1b2086670bfa06cdb148a9dbe61cd41680f2e 100644
|
|
--- a/src/fake-timers-src.js
|
|
+++ b/src/fake-timers-src.js
|
|
@@ -2,14 +2,14 @@
|
|
|
|
const globalObject = require("@sinonjs/commons").global;
|
|
let timersModule, timersPromisesModule;
|
|
-if (typeof require === "function" && typeof module === "object") {
|
|
+if (typeof __vitest_required__ !== 'undefined') {
|
|
try {
|
|
- timersModule = require("timers");
|
|
+ timersModule = __vitest_required__.timers;
|
|
} catch {
|
|
// ignored
|
|
}
|
|
try {
|
|
- timersPromisesModule = require("timers/promises");
|
|
+ timersPromisesModule = __vitest_required__.timersPromises;
|
|
} catch {
|
|
// ignored
|
|
}
|
|
@@ -537,7 +537,7 @@ function withGlobal(_global) {
|
|
isPresent.hrtime && typeof _global.process.hrtime.bigint === "function";
|
|
isPresent.nextTick =
|
|
_global.process && typeof _global.process.nextTick === "function";
|
|
- const utilPromisify = _global.process && require("util").promisify;
|
|
+ const utilPromisify = _global.process && _global.__vitest_required__ && _global.__vitest_required__.util.promisify;
|
|
isPresent.performance =
|
|
_global.performance && typeof _global.performance.now === "function";
|
|
const hasPerformancePrototype =
|