jenniferabowd / jest_webpack_example

MIT License
63 stars 25 forks source link

Add example on how to mock dynamic imports in jest #6

Open satyanash opened 5 years ago

satyanash commented 5 years ago

Dynamic imports (import("foo").then(foo => foo("bar")).catch(()=>console.log("import error")) are actually not supported in Node. As I understand it, these are transpiled to CommonJS imports before running the tests. There may be a need to help people understand how to mock success and failure of these imports in their jest tests.

jenniferabowd commented 5 years ago

Would you like to add it? If so, I'll happily merge the PR. If not, it might be a little bit of time till I can update it.