Skip to content

Commit 30f7317

Browse files
xtianpenalosapetebacondarwin
authored
Fix fromVitest conditional (#7260)
* Fix `fromVitest` conditional Checking for `/node_modules/vitest/` does not work with Yarn's pnpm linker, where the path is something like `node_modules/.store/vitest-virtual-ee893ec3ea/` * Use regex instead * Create lemon-deers-speak.md * fixup! Create lemon-deers-speak.md --------- Co-authored-by: Somhairle MacLeòid <[email protected]> Co-authored-by: Peter Bacon Darwin <[email protected]>
1 parent 4e69fb6 commit 30f7317

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/lemon-deers-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/vitest-pool-workers": patch
3+
---
4+
5+
Support Yarn `.store` directory

packages/vitest-pool-workers/src/worker/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ const monkeypatchedSetTimeout = (...args: Parameters<typeof setTimeout>) => {
7171
const [callback, delay, ...restArgs] = args;
7272
const callbackName = args[0]?.name ?? "";
7373
const callerFileName = getCallerFileName(monkeypatchedSetTimeout);
74-
const fromVitest = callerFileName?.includes("/node_modules/vitest/");
74+
const fromVitest = /\/node_modules\/(\.store\/)?vitest/.test(
75+
callerFileName ?? ""
76+
);
7577

7678
// If this `setTimeout()` isn't from Vitest, or has a non-zero delay,
7779
// just call the original function

0 commit comments

Comments
 (0)