babel-plugin-stub-import
Test importing variable specifier and filepath, then replace to stub.
Limitation
Stub is imported from default export, named exports is unavailable.
Usage
babel.config.js
moduleexports = "plugins": "babel-plugin-stub-import" "test": "importName": "^foo$" "stubTo": "<rootDir>/Stub"
Input
Output
; // unmatched specifiers are imported fron original; // matched specifier is imported from stub ; // import is stubbed but specifier is preserved.
For details, see tests
Options
Name | Type | Description |
---|---|---|
test.importName |
string\|RegExp |
Pattern to test import name and replace stub if matched. |
test.importPath |
string\|RegExp |
Pattern to test import path and replace stub if matched. |
stubTo |
string |
String to replace stub module. <rootDir> is replaced to root directory path. |