JEST problem z przetworzeniem zależnośći

0

JEST nie może przetworzyć dependency z node_modules a konkretnie chodzi kawałek kodu:

C:\Users\Mateusz\app\node_modules\vue-cli-plugin-electron-builder\lib\index.js:1
    export { default as installVueDevtools } from './installVueDevtools'
    ^^^^^^

Z tego co JEST wyrzuca wychodzi na to, że domyślnie nie przetwarza on (przy użyciu babela) nic z katalogu node_modules:

 Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

I zgodnie z zaleceniami zainstalowałem ``"babel-preset-env": "^1.7.0" oraz zmodyfikowałem jest.config.js aby babel mógł go przetworzyć:

module.exports = {
    preset: 'ts-jest',
    testEnvironment: 'node',
    testRegex: '/test/modules/.*\\.(test|spec)?\\.(ts|tsx)$',
     transform: {
         "^.+\\.js": "<rootDir>/node_modules/babel-jest"
     },
    transformIgnorePatterns: [
        "<rootDir>/node_modules/(?!vue-cli-plugin-electron-builder)"
    ],
    moduleNameMapper: {
        "@/(.*)": "<rootDir>/src/$1",
        "@assets/(.*)": "<rootDir>/test/assets/$1" //testing assets
    }
};

Po czym wyrzuca babel wewnętrzny błąd przetwarzania:

TypeError: C:\Users\Mateusz\app\node_modules\vue-cli-plugin-electron-builder\lib\installVueDevtools\index.js: Cannot read property 'bindings' of null

      at Scope.moveBindingTo (node_modules/@babel/traverse/lib/scope/index.js:925:13)
      at BlockScoping.updateScopeInfo (node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)      at BlockScoping.run (node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)
      at PluginPass.BlockStatementSwitchStatementProgram (node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)
      at newFn (node_modules/@babel/traverse/lib/visitors.js:179:21)
      at NodePath._call (node_modules/@babel/traverse/lib/path/context.js:55:20)
      at NodePath.call (node_modules/@babel/traverse/lib/path/context.js:42:17)
      at NodePath.visit (node_modules/@babel/traverse/lib/path/context.js:90:31)
      at TraversalContext.visitQueue (node_modules/@babel/traverse/lib/context.js:112:16)
      at TraversalContext.visitSingle (node_modules/@babel/traverse/lib/context.js:84:19)

Na co bezskutecznie staram się coś zaradzić, macie może jakieś pomysły?

Z góry dzięki

1

Odniosę się do użycia zapisu .* - co było powodem użycia zachłannego dopasowania czegokolwiek? Rozszerzanie zakresu dopasowania rzadko jest potrzebne i lepiej mieć dobry powód, żeby tak robić - kiedy inne sposoby zawiodły albo nie są tak dobre.

1 użytkowników online, w tym zalogowanych: 0, gości: 1