Skip to content

Add testing library #111

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

Merged
merged 6 commits into from
May 10, 2025
Merged

Add testing library #111

merged 6 commits into from
May 10, 2025

Conversation

crookedneighbor
Copy link
Collaborator

Proposal to allow us to write tests for components. I chose to do just one test as a demo. If this looks good, we can add more , if not, we can just close this PR.

Considerations:

  • I'm sure there's a better way to handle the vuex store, but I'm not sure what the strategy is
  • I set the environment to jsdom, but we could use something like happy-dom if we wanted an alternative
  • We could alternatively use vue test utils instead, but I really like testing library for it's focusing on encouraging best practices for accessibility with it's selectors

Copy link
Collaborator

@scarletcs scarletcs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!! Getting something like this set up has been on my mental todo for a bit. :)

  • Vuex store: Ideally, we run it integrated. We do not mock dispatch. We do not mock up its values. Instead, we have a fully instantiated store, we let the component dispatch updates to it, and we test that it updates as expected based on the state update it dispatched. My only concern there is finding the correct way to make Vuex and testing-libraries get along, given (unlike in the world of React) the store is not provided with a new one constructed per render() call.
  • I've never actually used happy-dom, I'm good with jsdom.
  • I'm a big fan of testing library too, so this is perfect to me.

@scarletcs
Copy link
Collaborator

scarletcs commented Apr 29, 2025

I've asked them for some documentation on what we ought to do here:

If need be I'll even consider switching to Pinia. The app is tiny, our store is tiny, it won't be a huge deal to change, it'll be fun getting some exposure to Pinia.

@crookedneighbor
Copy link
Collaborator Author

I’ve heard really good things about Pinia!

@crookedneighbor crookedneighbor merged commit a8ba5b8 into main May 10, 2025
1 check passed
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