question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Producing a single test bundle

See original GitHub issue

If I add preprocessors: {'**/*_test.js': ['webpack']} and I have 100s of tests, that produces 100s of large bundles - that’s slow, reruns tests all the time since karma keeps detecting changes and rerunning all ests as each test bundle is produced by webpack and this sends many megabytes to the test browser to evaluate.

Instead, if I add preprocessors: {"test_index.js": ['webpack']} and require all my tests in that file (e.g. here then webpack produces 1 test bundle. However, now I have to manually maintain the full list of all my tests which doesn’t scale.

I don’t know enough about karma plugins or webpack yet, but do you reckon there’s a way to configure webpack/karma/karma-webpack to produce ony 1 test bundle from a pattern such as **/*_test.js?

Perhaps something like dynamically, via the karma-webapck plugin, adding configuration about which modules to force include even if they’re not required (is there such option?)

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:4
  • Comments:19 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
plasticinecommented, Sep 11, 2014

I should mention that the one down-side to this technique that I’ve noticed is that it breaks watch mode for subsequently required files — only the test_index will trigger a karma rebuild.


Edit: I am an idiot 😃

This works perfectly…

files: [
  'test/test_helper.js',
  'test/test_index.js',
  { pattern: 'test/**/*_test.*', included: false, served: false, watched: true }
]
6reactions
joniracommented, Aug 4, 2015

I’m having the following issue: Karma detects file changes, but executes the old version of the file. Terminating and restarting karma causes the changed version of the file to be executed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Producing a single test bundle · Issue #23 - GitHub
Personally I think it is a better default to have one bundle for all the test files. For our unit test specs, we...
Read more >
How to create a Bundle in a Unit test - Stack Overflow
Use Robolectric framework that provides some kind of shadow classes for your unit tests. This allows you to use Android specific classes in...
Read more >
Testing the Bundle - SymfonyCasts
Adding Tests to your Bundle & autoload-dev​​ Time to move this into our bundle. We already have a src/ directory. Now create a...
Read more >
Build and test your Android App Bundle
Automating deployment your app from an app bundle to one or more connected test devices. Emulating downloads of your app from Google Play ......
Read more >
Preparing your App and Test Bundles - Experitest
Creating App and Test Bundles ... It is the developer's responsibility to create paired bundles, one being the app bundle and the other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found