Skip to content

Conversation

backyardcoder
Copy link

@backyardcoder backyardcoder commented Mar 9, 2020

The primary reason to introduce this change is to provide a way to aid the testing of components that consumes a Loadable component.
For example:

// In source code file:
const MyComponent = Loadable({
  displayName: 'MyComponent', // same as the import name and guaranteed to be unique in the "sut"
  loader: () => ...,
  loading: () => ...
});

// In test file
import MyComponent from '../my-path';

fakeLoader.withArgs({
   displayName: 'MyComponent',
   loader: sinon.match.func,
   loading: sinon.match.func
}).returns(MyComponent);

With the help of displayName, one can use a package like proxyquire to set up the correct fake loader stub to return expected components.

@backyardcoder
Copy link
Author

What do you think about adding this support, @jamiebuilds @tajo?

@StefanMcCready
Copy link

StefanMcCready commented Jul 1, 2020

It would be super cool to have this as part of the project. For a certain project, I am relying on the component displayName to help pick out certain components from children. Since we have moved to use react-loadable we have not been able to do this.

Repository owner deleted a comment from ygs-code Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants