codymikol / karma-webpack

Karma webpack Middleware
MIT License
830 stars 221 forks source link

test: add initial preprocessor test #501

Closed rigor789 closed 1 year ago

rigor789 commented 3 years ago

This PR contains a:

Motivation / Use-Case

While working on NativeScript unit test runner, we ran into a few issues with the default config/setup of karma-webpack (5), however we were able to adjust the default config by simply patching it, so decided not to make changes & bloat karma-webpack with an extra flag/escape hatch.

One small "issue" remains with how the file.path is handled. The original (full) path is discarded, so karma-server's context.json contains:

/absolute<testname>.<hash>.js?<anotherHash>
# instead of 
/base/<original-path>/<testname>.<hash>.js?<anotherHash>

# For example:
/app/tests/example.spec.js
# would become
/absoluteexample.spec.123123.js?hashhashhash

but unsure if changing that would affect anything else, we adjusted how we handle paths starting with /absolute - so no change required in karma-webpack from our end.

Breaking Changes

N/A

Additional Info

The change in controller.test.js fixes the test on non-unix systems.

The test doesn't currently cover the // one time setup block.