redux-persist - 5.9.1
react - 16.3.2
jest - 22.4.3
import storage from "redux-persist/es/storage";
({"Object.
^^^^^^
SyntaxError: Unexpected token import
23 | key: "root",
24 | storage,
> 25 | whitelist: ["provider", "location", "user"]
26 | };
27 |
28 | const combinedReducer = persistCombineReducers(config, reducers);
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)
at Object.<anonymous> (app/javascript/bundles/ReduxProvider.jsx:25:16)
at Object.<anonymous> (app/javascript/bundles/AdminPanel/Location/containers/EditLocationContainer.jsx:13:22)
I also tried with
import storage from "redux-persist/lib/storage";
import React, { PureComponent } from 'react'; // eslint-disable-line import/no-unresolved
^^^^^^
SyntaxError: Unexpected token import
29 |
30 | let AppStore = configureStore(combinedReducer);
> 31 | let persistor = persistStore(AppStore);
32 |
33 | export default class ReduxProvider extends React.Component {
34 | render() {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)
at Object.<anonymous> (app/javascript/bundles/ReduxProvider.jsx:31:15)
at Object.<anonymous> (app/javascript/bundles/AdminPanel/Location/containers/EditLocationContainer.jsx:13:22)
console.error node_modules/redux-persist/lib/storage/getStorage.js:40
redux-persist failed to create sync storage. falling back to memory storage.
seems like the jest is not compile the library, try to add the config on the jest config file? you can refer jest documents
Same issue here.
I'm trying to write tests using ...
"devDependencies": {
"@types/enzyme": "^3.1.11",
"@types/enzyme-adapter-react-16": "^1.0.2",
"@types/faker": "^4.1.2",
"@types/fetch-mock": "^6.0.3",
"@types/jest": "^23.1.3",
"@types/react-test-renderer": "^16.0.1",
"@types/redux-mock-store": "^1.0.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"faker": "^4.1.0",
"fetch-mock": "^6.4.4",
"react-scripts-ts": "^2.16.0",
"react-test-renderer": "^16.4.1",
"redux-mock-store": "^1.5.3",
"typescript": "2.9.2"
}
but I'm getting the below error when import storage from "redux-persist/lib/storage";
$ yarn test
yarn run v1.7.0
$ react-scripts-ts test --env=jsdom
console.error node_modules\redux-persist\lib\storage\getStorage.js:40
redux-persist failed to create sync storage. falling back to memory storage.
and same error as @HeratPatel1 's when import storage from "redux-persist/es/storage";
I'm also running into the same problem. Also tried to switch from import storage from "redux-persist/es/storage" to import storage from "redux-persist/lib/storage" but the error ... persist (no pun intended).
Most helpful comment
Same issue here.
I'm trying to write tests using ...
but I'm getting the below error when
import storage from "redux-persist/lib/storage";and same error as @HeratPatel1 's when
import storage from "redux-persist/es/storage";