FormidableLabs / jest-next-dynamic

Resolve Next.js dynamic import components in Jest tests
MIT License
69 stars 7 forks source link

Broken as of Next 8.0.4 #6

Closed KB1RMA closed 5 years ago

KB1RMA commented 5 years ago

Upgrading from 8.0.3 ->8.0.4 it appears this has broken unfortunately.

I now get the error:

Cannot find module 'function () {
            return (0, _interopRequireWildcard2.default)(require('./Search/Search'));
          }' from 'Header.js'

image

KB1RMA commented 5 years ago

I did a little more digging into the changelog and it looks like this PR https://github.com/zeit/next.js/pull/6811 adding babel-plugin-dynamic-import-node might have been conflicting with my own config:

I had "babel-plugin-dynamic-import-node": "^2.2.0", listed as a dependency and:

env: {
    test: {
      plugins: ['dynamic-import-node'],
    },
  },

Listed in my babel.config.js. Removing both the dep and the config entry appears to have solved the problem.

Maybe the best thing would be to note that above 8.0.4 dynamic-import-node plugin isn't required anymore? Assuming anyone else actually has this problem.