-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shouldn't run all modules by default #42
Comments
@jamesshore this is interesting. What kind of odd behaviour are you seeing in your tests? That is - what is the practical problem with this approach? Somehow we should treat all tests being executed as "entry points" but I'm not sure how we could detect those... |
I ran across when trying to Anyway, that got me thinking about correct behavior and I realized that running modules before they were require'd was actually incorrect. |
I encountered the same thing while making https://www.npmjs.com/package/karma-common-js, which is basically a fork of karma-commonjs. The issues I had was that since modules were initialized in random order, subtle bugs appeared in the tests that were hard to figure out. When I added the ability to specify one or more entry points for the tests, all those issues were gone. An example was a test which overrides window.setTimeout. When that wasn't started first, other modules could use setTimeout before it was mocked. |
In commonjs_bridge.wrapper, karma-commonjs "requires" all files. This has the effect of running all files, which can cause odd behavior. The correct behavior is only to run files when a
require
statement is encountered.I'm not sure what we should do here, but I think we need some sort of "entry point" configuration that says which files should be run.
The text was updated successfully, but these errors were encountered: