Skip to content

Commit

Permalink
fix jest transpiling all node modules, make tests fast again
Browse files Browse the repository at this point in the history
the previous regexp is bugged, it requires '//' in the filename !!
As a result, all the files in node_modules don't pass the regex
so nothing is ignored => everything is transformed

jest caches this in /tmp/jest_* so rerunning tests is fast, but
the first time jest takes minutes to transform everything

also the previous config was incomplete for moduleNameMapper but this was not
visible because it transformed everything anyway:
    Jest encountered an unexpected token
    Details:
       /node_modules/ag-grid-community/styles/ag-grid.css:1
       ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){.ag-icon {
                                                                                         ^
       SyntaxError: Unexpected token '.'

    Details:
       /node_modules/react-dnd/dist/index.js:1
       ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export * from './core/index.js';
                                                                                         ^^^^^^
    SyntaxError: Unexpected token 'export'
  • Loading branch information
jonenst committed Jul 15, 2024
1 parent 4d043b7 commit 5654f67
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@
},
"jest": {
"moduleNameMapper": {
"\\.svg": "<rootDir>/src/__mocks__/svgrMock.js"
"\\.svg": "<rootDir>/src/__mocks__/svgrMock.js",
"^.+\\.(css|less|scss)$": "identity-obj-proxy"
},
"transformIgnorePatterns": [
"node_modules/(?!@gridsuite/commons-ui)/"
"node_modules/(?!@gridsuite/commons-ui|react-dnd|dnd-core|@react-dnd)"
]
},
"eslintConfig": {
Expand Down

0 comments on commit 5654f67

Please sign in to comment.