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

后端 未结 3 560
一生所求
一生所求 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条回答
  •  -上瘾入骨i
    2020-12-16 02:21

    Maybe your own preprocessor file will be the solution:

    ScriptPreprocessor

    Custom-preprocessors

    scriptpreprocessor: The path to a module that provides a synchronous function from pre-processing source files. For example, if you wanted to be able to use a new language feature in your modules or tests that isn't yet supported by node (like, for example, ES6 classes), you might plug in one of many transpilers that compile ES6 to ES5 here.

    I created my own preprocessor when I had a problems with my tests after added transform-decorators-legacy to my webpack module loaders.

提交回复
热议问题