All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Handle case where identifier referring to import is renamed by another Babel
plugin after the call to
$imports.$add
is generated #25
- Support selectively restoring/undoing mocks by passing an argument to
$restore
#23
- Support mocking CommonJS imports of a specific export in the form
var alias = require("module/path").exportName
orvar alias = require("module/path")["exportName"]
#22
- Fix a bug where functions passed to
$imports.$mock
were processed as both objects and functions #16
- Fix a bug where calls to
$imports.$add
were added to the top-level of the module but were not statements. This invalid output caused problems when the plugin was used together with some other Babel plugins
- Support passing a function to
$mock
to semi-automatically mock imports based on the source, symbol name or original value (#14)
- Ignore Babel-generated CommonJS imports (robertknight#8). The plugin uses the heuristic that CommonJS imports are auto-generated if the variable name starts with an underscore.
- Support CommonJS imports with separate variable declaration and initialization (#5)
- Make CommonJS imports which use destructuring mockable when the babel-transform-object-destructuring plugin is enabled (#4)
- Fix use of CommonJS imports if variable declarations before the last CommonJS import in the file references them (#4)
- Support mocking of CommonJS / Node-style imports (
var aModule = require("a-module")
) - Support excluding imports from certain modules from being transformed for
mock-ability, via the
excludeImportsFromModules
option - Support excluding modules from certain directories from being processed by
this plugin via the
excludeDirs
option. By default this is configured to avoid transforming tests - Fix CommonJS default exports (
module.exports = <expression>
) overwriting the$imports
export - Use more robust logic to avoid rewriting references to imports in the
initialization of the
$imports
variable in generated code
- Initial release