I want to test a component which dynamically imports another component.
The test is running but I get a warning:

warning

Here is my .babelrc :

{
  "plugins": ["@babel/plugin-syntax-dynamic-import"],
  "presets": [
    ["@babel/env", {
      "modules": false
    }]
  ],
  "env": {
    "test": {
      "presets": [
        ["@babel/env", {
          "targets": {
            "node": "current"
          }
        }]
      ]
    }
  }
}

And my jest.config.js

module.exports = {
  moduleFileExtensions: [
    'js',
    'json',
    // tell Jest to handle *.vue files
    'vue',
  ],
  transform: {
    // process js with babel-jest
    '^.+\\.js$': '<rootDir>/node_modules/babel-jest',
    // process *.vue files with vue-jest
    '.*\\.(vue)$': '<rootDir>/node_modules/vue-jest',
  },
  // support the same @ -> src alias mapping in source code
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/$1',
  },
  // serializer for snapshots
  snapshotSerializers: [
    '<rootDir>/node_modules/jest-serializer-vue',
  ],
};

How can I resolve this warning/error?

0 Answers