Cannot use import.meta outside a module. Vite testing

Viewed 1582

I'm using vite and jest for testing. When i run my tests i get this error

This is my .babelrc file babelrc

and this my vite.config vite config

Does anyone have a solution for this? I've searched and didn't find any answer

FIX: I added this on babel.config.js

//babel.config.js

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      { useBuiltIns: 'entry', corejs: '2', targets: { node: 'current' } },
    ],
  ],
  plugins: [
    function () {
      return {
        visitor: {
          MetaProperty(path) {
            path.replaceWithSourceString('process')
          },
        },
      }
    },
  ],
}

0 Answers
Related