From b7471e90900794c5b5bb01cfe269056fb079b209 Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Mon, 9 Oct 2023 08:13:01 -0700 Subject: [PATCH] fix: ensure custom resolver used for older versions of jest --- src/preset/browser/jest-preset.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/preset/browser/jest-preset.ts b/src/preset/browser/jest-preset.ts index 1fd26ef..835b5cd 100644 --- a/src/preset/browser/jest-preset.ts +++ b/src/preset/browser/jest-preset.ts @@ -13,10 +13,21 @@ export = { }; function needsResolver() { - const version = getVersion("@marko/compiler") || getVersion("marko"); - if (!version) return false; + const jestVersion = getVersion("jest"); - const parts = version.split("."); + // Jest 29+ has a built in resolver that works fine with newer + // versions of Marko. Older versions of jest always require a custom resolver. + if ( + jestVersion && + parseInt(jestVersion.slice(0, jestVersion.indexOf(".")), 10) < 29 + ) { + return true; + } + + const markoVersion = getVersion("@marko/compiler") || getVersion("marko"); + if (!markoVersion) return false; + + const parts = markoVersion.split("."); const major = parseInt(parts[0], 10); const minor = parseInt(parts[1], 10); const patch = parseInt(parts[2], 10);