Do you want to request a _feature_ or report a _bug_?
Bug
What is the current behavior?
Having such require syntax in sources cause jest error:
const resBundle = require(
'i18next-resource-store-loader!i18n/locales/index.js'
);
Error:
Test suite failed to run
Cannot find module 'i18next-resource-store-loader!i18n/locales/index.js' from 'i18n.js'
...
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:169:17)
What is the expected behavior?
I want to run my tests !
Please provide your exact Jest configuration
"jest": {
"coverageDirectory": "./coverage/",
"collectCoverageFrom": [
"src/**/*.js"
],
"moduleNameMapper": {
"\\.(scss|less)$": "identity-obj-proxy"
},
"modulePaths": [
"<rootDir>/src/"
],
"setupFiles": [
"<rootDir>/src/__mocks__/localStorageMock.js"
]
}
Is there any workarounds ?
Thank you!
See https://facebook.github.io/jest/docs/en/webpack.html
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
I'm not asking help, I'm reporting a bug in Jest
No you're not, you're trying to use webpack specific syntax outside of webpack, and I linked to the relevant docs
same problem...
any tips?
Same here
same problem...
Going to try and explain this a little clearer. The file you're importing is:
i18next-resource-store-loader!i18n/locales/index.js
This import has two parts:
i18next-resource-store-loader!
webpack loaderi18n/locales/index.js
fileThe first is a webpack loader. Jest does not know how to run webpack loaders, so we don't know how to require this file
Most helpful comment
Going to try and explain this a little clearer. The file you're importing is:
i18next-resource-store-loader!i18n/locales/index.js
This import has two parts:
i18next-resource-store-loader!
webpack loaderi18n/locales/index.js
fileThe first is a webpack loader. Jest does not know how to run webpack loaders, so we don't know how to require this file