Here's the error I'm getting:
Test suite failed to run
TypeError: memoizeCapped is not a function
at Object.<anonymous> (node_modules/cheerio/node_modules/lodash/_stringToPath.js:17:20)
at Object.<anonymous> (node_modules/cheerio/node_modules/lodash/_castPath.js:3:20)
at Object.<anonymous> (node_modules/cheerio/node_modules/lodash/_baseGet.js:1:105)
at Object.<anonymous> (node_modules/cheerio/node_modules/lodash/get.js:1:104)
at Object.<anonymous> (node_modules/cheerio/node_modules/lodash/_baseMatchesProperty.js:2:11)
at Object.<anonymous> (node_modules/cheerio/node_modules/lodash/_baseIteratee.js:2:27)
at Object.<anonymous> (node_modules/cheerio/node_modules/lodash/some.js:2:20)
at Object.<anonymous> (node_modules/cheerio/lib/api/attributes.js:13:13)
at Object.<anonymous> (node_modules/cheerio/lib/cheerio.js:21:3)
at Object.<anonymous> (node_modules/cheerio/index.js:5:28)
at Object.<anonymous> (node_modules/enzyme/build/render.js:10:16)
at Object.<anonymous> (node_modules/enzyme/build/index.js:21:15)
at Object.<anonymous> (node_modules/enzyme-matchers/lib/assertions/toContainReact.js:7:15)
at Object.<anonymous> (node_modules/enzyme-matchers/lib/index.js:23:23)
at Object.<anonymous> (node_modules/jest-enzyme/lib/index.js:5:23)
at Generator.next (<anonymous>)
at Promise (<anonymous>)
at Generator.next (<anonymous>)
at <anonymous>
Yet the _memoizeCapped function the _stringToPath is trying to include is indeed there. I use get all the time with the latest lodash so I don't think it's lodash causing the issue here. Any ideas? I've tried every configuration/etc thing I can think of that would be an issue.
Jest config in package.json:
"jest": {
"unmockedModulePathPatterns": [
"react",
"enzyme",
"jest-enzyme"
],
"moduleNameMapper": {
"\\.(jpe?g|png|gif|eot|otf|webp|svg|ttf|woff2?|mp[34]|webm|wav|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less|s[ac]ss|styl)$": "<rootDir>/__mocks__/styleMock.js",
"app": "<rootDir>/src/app.js"
},
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": [
"src",
"src/js",
"node_modules"
],
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js"
},
.babelrc:
{
"presets": [
[
"env",
{
"modules": false,
"targets": { "browsers": "ie >= 11, ff >= 46, > 1%" },
"useBuiltIns": true,
"debug": false
}
],
"react"
],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread"
//'react-hot-loader/babel',
],
"env": {
"test": {
"presets": [
"env",
// {
// "modules": false,
// "targets": { "browsers": "ie >= 11, ff >= 46, > 1%" },
// "useBuiltIns": true,
// "debug": false
// }
"react"
],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread",
"transform-export-extensions"
],
"only": ["./**/*.js", "node_modules/jest-runtime"]
}
}
}
Still an issue for me. Can't run any of cheerio without this fixed and it's preventing me from upgrading to React16 which is a bit frustrating. I'll cross post to lodash maybe.
@Tetheta I'm not sure whether this problem is caused by cheerio. I fixed the problem with adding the https://github.com/59naga/babel-plugin-add-module-exports module. Here my .babelrc
{
"presets": ["env", "react", "flow"],
"env": {
"test": {
"plugins": [ "add-module-exports"],
"presets": ["env", "react"]
}
}
}
and jest configuration
{
"unmockedModulePathPatterns": [
"react",
"enzyme",
"jest-enzyme"
],
"moduleNameMapper": {
"\\.(jpe?g|png|gif|eot|otf|webp|svg|ttf|woff2?|mp[34]|webm|wav|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less|s[ac]ss|styl)$": "<rootDir>/__mocks__/styleMock.js",
"app": "<rootDir>/src/app.jsx"
},
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": [
"src",
"node_modules"
]
}
There are a babel packages which I used
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-jest": "^21.2.0",
"babel-loader": "^7.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.0",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-runtime": "^6.26.0",
Apologies for forgetting to comment, but thanks a bunch @captainkovalsky ! This was indeed my issue (or at least let me see the other issues I had finally). Got it working after a bit more tweaking. I'll close this issue now.
Most helpful comment
@Tetheta I'm not sure whether this problem is caused by cheerio. I fixed the problem with adding the https://github.com/59naga/babel-plugin-add-module-exports module. Here my
.babelrcand jest configuration
There are a babel packages which I used