Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,28 @@ const config = {

testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/.next/"],

transformIgnorePatterns: [
"/node_modules/",
"^.+\\.module\\.(css|sass|scss)$",
],
transformIgnorePatterns: ["^.+\\.module\\.(css|sass|scss)$"],
verbose: true,
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(config);
module.exports = async () => {
const fn = createJestConfig(config);
const actualConfig = await fn();

// 1. Locate the default pattern that ignores node_modules
// (It usually looks like '/node_modules/' or 'node_modules/')
const transformIgnorePatterns = actualConfig.transformIgnorePatterns.filter(
pattern => pattern !== "/node_modules/" && pattern !== "node_modules/",
);

// 2. Add your whitelist pattern to the START of the list
// We use a wildcard for hast-util-* and unist-util-* to catch the deep dependency tree
return {
...actualConfig,
transformIgnorePatterns: [
"node_modules/(?!(refractor|hastscript|hast-util-.*|unist-util-.*|vfile|vfile-location|property-information|space-separated-tokens|comma-separated-tokens|web-namespaces|html-void-elements|character-entities|zwitch|ccount|markdown-table)/)",
...transformIgnorePatterns,
],
};
};
Loading
Loading