Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Jest to 27.2.0 #13776

Merged
merged 2 commits into from Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -59,8 +59,8 @@
"gulp-filter": "^5.1.0",
"gulp-plumber": "^1.2.1",
"husky": "^3.0.0",
"jest": "^27.0.0",
"jest-worker": "^27.0.2",
"jest": "^27.2.0",
"jest-worker": "^27.2.0",
"lint-staged": "^9.2.0",
"lodash": "^4.17.21",
"mergeiterator": "^1.2.5",
Expand Down
28 changes: 24 additions & 4 deletions test/jestExportsMapResolver.cjs
@@ -1,11 +1,31 @@
// Temporary workaround for https://github.com/facebook/jest/issues/9771
// Source: https://github.com/facebook/jest/issues/9771#issuecomment-841624042

const resolver = require("enhanced-resolve").create.sync({
conditionNames: ["node", "require", "default"],
extensions: [".js", ".json", ".node", ".ts"],
});
const enhancedResolve = require("enhanced-resolve");

const EXTENSIONS = [".js", ".json", ".node", ".ts"];

function mapGetOr(map, key, init) {
if (!map.has(key)) {
map.set(key, init());
}
return map.get(key);
}

const resolversCache = new Map();
function getResolver(conditionNames) {
const cacheKeySeparator = ":::";
const cacheKey = conditionNames.join(cacheKeySeparator);

return mapGetOr(resolversCache, cacheKey, () =>
enhancedResolve.create.sync({
conditionNames,
extensions: EXTENSIONS,
})
);
}

module.exports = function (request, options) {
const resolver = getResolver(options.conditions || ["default"]);
return resolver(options.basedir, request);
};