marvinhagemeister / karma-esbuild

Preprocessor based on esbuild for the karma test runner
MIT License
21 stars 10 forks source link

Allow user's esbuild config to override `platform` #40

Open evanwalsh opened 3 years ago

evanwalsh commented 3 years ago

This is a simple change that won't be useful for most users of this library. However, I'm trying to use karma-esbuild with some tests that run in an Electron app that has full Node.js access within its renderer.

While running Karma tests that're compiled with karma-esbuild, I get errors like:

ERROR [esbuild]: Build failed with 1 error:
src/helpers/fs.ts:1:40: error: Could not resolve "fs" (use "platform: 'node'" when building for node)

This PR lets the user's config override the default browser platform. I looked into adding tests for this, but the best way to do it would be to setup a whole Electron config within a fixture, which might be an extra dependency you'd rather not have here for a single line getting moved.

Let me know and I can make it happen! Thanks to everyone that has worked on this library and made it so easy to integrate.

jridgewell commented 3 years ago

I wonder if there's a way to add a test case for this.