karma-runner / karma-commonjs

A Karma plugin. Test CommonJS modules.
MIT License
73 stars 30 forks source link

feat: load from the node_modules folder hierarchy #30

Closed pkozlowski-opensource closed 10 years ago

pkozlowski-opensource commented 10 years ago

Fixes #21

This is the last step in supporting node's algorithm for loading modules. With this change we are going to look into the node_modules subfolder of a requiring file and traverse folders hierarchy upwards till a required file is found. I'm going to keep the "root folder" setting for now as it might be used to override certain modules in testing, for example.

This commit concludes several-months effort of making karma's load algorithm as close to the node's one as possible. The only remaining part is dealing with native modules but I don't think this is something we want to support. At least personally I don't have use-case for it.

There are probably corner cases not covered and the implementation could be better but well, we will deal with those issues as they surface.