Skip to content

Commit

Permalink
fix: ensure custom resolver used for older versions of jest
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Oct 9, 2023
1 parent 068d23b commit b7471e9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/preset/browser/jest-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b7471e9

Please sign in to comment.