zinserjan / mocha-webpack

mocha test runner with integrated webpack precompiler
http://zinserjan.github.io/mocha-webpack/
MIT License
485 stars 75 forks source link

Update Documentation #235

Open markandan opened 6 years ago

markandan commented 6 years ago

Hi,

While following the steps given in the documentation. I came across the following error

"Syntax error: 'import' and 'export' may appear only with 'sourceType: "module"'"

I searched and found that we need to add one configuration (highlighted in bold below)

{ test: /.(js|ts)/, include: path.resolve('src'), // instrument only testing sources with Istanbul, after ts-loader runs loader: 'istanbul-instrumenter-loader', query: { esModules: true } }

zinserjan commented 6 years ago

Thanks for reporting.

Does esModules: true work with require statements, too? I'm just asking cause babel may be configured with transpiling modules to commonjs.

Can you create a PR to update the docs?

markandan commented 6 years ago

Pull request created. It works with require statement as well.

tsjensen commented 4 years ago

Thanks for posting this! I hope this crucial piece of information makes it into the main docs one day.