-
Notifications
You must be signed in to change notification settings - Fork 128
refactor: add canned mock of exports from api-command #642
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
Conversation
|
f9e5c0b to
02486ad
Compare
| apiCommandBuilder: apiCommandBuilderMock, | ||
| apiDocsURL: apiDocsURLMock, | ||
| })) | ||
| const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love that we need to pass in the directory prefix here but jest.unstable_mockModules works relative to the test itself. There might be a way to determine this in the module but I haven't found anything yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a better way either. I suppose you could at least set a default (probably of ../../..) so you don't always have to pass it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had considered that but decided against it because I was afraid someone (like me 😄) might cut-and-paste one without the value specified and wonder why it didn't work.
I've also just realized the small sample of use-cases we have right now might not be representative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this for a nanosecond longer and I'm realizing we probably do have more commands at one level deep overall so maybe we should make a default of ../../..? 🤷
| apiCommandBuilder: apiCommandBuilderMock, | ||
| apiDocsURL: apiDocsURLMock, | ||
| })) | ||
| const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a better way either. I suppose you could at least set a default (probably of ../../..) so you don't always have to pass it?
This an example of an attempt at making the unit tests a little less repetitive.