Skip to content

Commit

Permalink
Only mock local components
Browse files Browse the repository at this point in the history
  • Loading branch information
lyzadanger committed Jul 27, 2021
1 parent f4cd377 commit d817815
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/util/mock-imported-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ function getDisplayName(component) {

/**
* Helper for use with `babel-plugin-mockable-imports` that mocks components
* imported by a file.
* imported by a file. This will only mock components that are local to the
* package; it will not mock external components. This is to aid in catching
* integration issues, at the slight cost of unit isolation.
*
* Mocked components will have the same display name as the original component,
* minus any wrappers (eg. `Widget` and `withServices(Widget)` both become
Expand All @@ -62,7 +64,7 @@ function getDisplayName(component) {
*/
export default function mockImportedComponents() {
return (source, symbol, value) => {
if (!isComponent(value)) {
if (!isComponent(value) || !source.startsWith('.')) {
return null;
}

Expand Down

0 comments on commit d817815

Please sign in to comment.