Skip to content
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

Only mock local components #156

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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