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

JEST transformIgnorePatterns not working #1947

Open
robvaneckalliander opened this issue Mar 8, 2024 · 5 comments
Open

JEST transformIgnorePatterns not working #1947

robvaneckalliander opened this issue Mar 8, 2024 · 5 comments
Labels

Comments

@robvaneckalliander
Copy link

    "@swimlane/ngx-charts": "^20.5.0",

    "@types/jest": "^29.5.12",
    "@types/node": "^18.18.0",
    "@typescript-eslint/eslint-plugin": "^6.19.0",
    "@typescript-eslint/parser": "^6.19.0",
    "jest": "^29.7.0",
    "jest-canvas-mock": "^2.5.2",
    "jest-environment-jsdom": "^29.7.0",
    "jest-preset-angular": "^14.0.3",

already tried:

jest.config.js

const esModules = ['@swimlane', '@swimlane*', 'd3', 'd3-array', 'd3-selection', 'd3-*'].join('|');

transformIgnorePatterns: [
    `<rootDir>/node_modules/(?!${esModules})`,
  ],

but still

d3-selection\src\index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export {default as create} from "./create.js";
                                                                                      ^^^^^^

    SyntaxError: Unexpected token 'export' 
@erwanbecquetdedalus
Copy link

Hello, same problem here.
Is there any updates on this ?
@robvaneckalliander did you find a way to bypass the problem ?
Thanks in advance.

@dananaprey
Copy link

dananaprey commented Jun 19, 2024

This line in jest.config.json helps me:
"transformIgnorePatterns": ["node_modules/(?!.*.mjs$|d3)"],

@rcsilva83
Copy link

Same problem here...

@dananaprey, this line didn't helped me :(

@rcsilva83
Copy link

This worked for me!

transformIgnorePatterns: ["<rootDir>/node_modules/(?!.*.mjs$|d3|internmap)"],

@mwamufiya
Copy link

mwamufiya commented Dec 13, 2024

In case the above transformIgnorePatterns didn't work for you like it did for me. based on this StackOverflow answer

using moduleNameMapper in your jest.config allowed me to get past this.

"moduleNameMapper": {
    "^d3-(.*)$": "<rootDir>/node_modules/d3-$1/dist/d3-$1.min.js"
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants