Skip to content

Conversation

@rossiam
Copy link
Collaborator

@rossiam rossiam commented Oct 29, 2024

This an example of an attempt at making the unit tests a little less repetitive.

@rossiam rossiam requested a review from Sitlintac October 29, 2024 18:40
@changeset-bot
Copy link

changeset-bot bot commented Oct 29, 2024

⚠️ No Changeset found

Latest commit: 02486ad

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

apiCommandBuilder: apiCommandBuilderMock,
apiDocsURL: apiDocsURLMock,
}))
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..')
Copy link
Collaborator Author

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.

Copy link
Contributor

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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 ../../..? 🤷

@rossiam rossiam marked this pull request as ready for review November 14, 2024 19:38
@rossiam rossiam requested a review from a team November 14, 2024 19:38
apiCommandBuilder: apiCommandBuilderMock,
apiDocsURL: apiDocsURLMock,
}))
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..')
Copy link
Contributor

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?

@rossiam rossiam merged commit da64393 into SmartThingsCommunity:yargs Nov 18, 2024
4 checks passed
@rossiam rossiam deleted the api-command-mocks branch November 18, 2024 15:26
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.

2 participants