How can I use my webpack's html-loader imports in Jest tests?

后端 未结 3 557
一生所求
一生所求 2020-12-16 01:18

I am just getting started with the Jest test framework and while straight up unit tests work fine, I am having massive issues testing any component that in its module (ES mo

3条回答
  •  天涯浪人
    2020-12-16 02:21

    A bit late to the party, but wanted to add that there is also this html-loader-jest npm package out there to do this if you wanted to go that route.

    Once you npm install it you will add it to your jest configuration with

    "transform": {
            "^.+\\.js$": "babel-jest",
            "^.+\\.html?$": "html-loader-jest"
        }
    

提交回复
热议问题