Enzyme: Cannot find module 'enzyme/build/ShallowWrapper' from 'utils.js'

Created on 25 Apr 2019  路  2Comments  路  Source: enzymejs/enzyme

Current behavior

When I run the test with jest it throw this error

Test suite failed to run

    Cannot find module 'enzyme/build/ShallowWrapper' from 'utils.js'

    However, Jest was able to find:
        './utils.js'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

    However, Jest was able to find:
        './createSerializer.js'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:229:17)
      at Object.<anonymous> (node_modules/enzyme-to-json/utils.js:16:23)

Expected behavior

the test should run

Your environment

jest, typescript, react, nodejs

API

  • [X] shallow
  • [ ] mount
  • [ ] render

Version

{
  "dependencies": {
    "@types/body-parser": "^1.17.0",
    "@types/cors": "^2.8.4",
    "@types/dotenv": "^6.1.1",
    "@types/express": "^4.16.1",
    "@types/moment": "^2.13.0",
    "@types/react": "^16.8.14",
    "@types/react-dom": "^16.8.4",
    "body-parser": "^1.18.3",
    "cors": "^2.8.5",
    "dotenv": "^7.0.0",
    "express": "^4.16.4",
    "lorem-ipsum": "^2.0.1",
    "moment": "^2.24.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "ts-node": "^8.1.0"
  },
  "devDependencies": {
    "@types/code": "^4.0.5",
    "@types/enzyme": "^3.9.1",
    "@types/enzyme-adapter-react-16": "^1.0.5",
    "@types/enzyme-to-json": "^1.5.3",
    "@types/jest": "^24.0.11",
    "babel-core": "^6.26.3",
    "babel-polyfill": "^6.26.0",
    "code": "^5.2.4",
    "enzyme-adapter-react-16": "^1.12.1",
    "enzyme-to-json": "^3.3.5",
    "jest": "^24.7.1",
    "react-test-renderer": "^16.8.6",
    "reflect-metadata": "^0.1.13",
    "ts-jest": "^24.0.2"
  }
}

Adapter

  • [X] enzyme-adapter-react-16
  • [ ] enzyme-adapter-react-16.3
  • [ ] enzyme-adapter-react-16.2
  • [ ] enzyme-adapter-react-16.1
  • [ ] enzyme-adapter-react-15
  • [ ] enzyme-adapter-react-15.4
  • [ ] enzyme-adapter-react-14
  • [ ] enzyme-adapter-react-13
  • [ ] enzyme-adapter-react-helper
  • [ ] others ( )
invalid question

Most helpful comment

I don't see enzyme itself in any of your deps. Perhaps you need npm install --save enzyme?

All 2 comments

I don't see enzyme itself in any of your deps. Perhaps you need npm install --save enzyme?

wow I didn't realize sorry :)

Was this page helpful?
0 / 5 - 0 ratings