Stack Overflow Asked by Prasad Sawant on December 23, 2021
We are using create-react-app to build our declarative framework. In this framework, we author a json file which gets loaded into a react-component by webpack. We have authored specific loader for that. This works well in the browser. But facing issues with unit testing. Create-react-app uses Jest for unit testing.
What I want to acheive is transform these json files in js or react component, but hitting following limitations
Need your guidance to resolve this issue.
Webpack Docs: https://webpack.js.org/loaders/json5-loader/ The Config for conversion of JSON to JS would look something like this. Then you could pass it into Jest rather than have Jest try to convert it during runtime.
module.exports = {
module: {
rules: [
{
test: /.json5$/i,
loader: 'json5-loader',
type: 'javascript/auto',
},
],
},
};
Answered by Jacob on December 23, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP