swup / fragment-plugin

A swup plugin for dynamically replacing containers based on rules 🧩
https://swup-fragment-plugin.netlify.app
MIT License
16 stars 1 forks source link

feat: add vitest tests #57

Closed hirasso closed 12 months ago

hirasso commented 12 months ago

Description

Add tests for the stuff that's testable without requiring browser navigation. After opening the issue about testing official plugins from inside swup's main package, I thought it would be worth it to try it the other way around – testing right from the plugins themselves. After creating all these tests, I've become a fan of this approach.

Next up: playwright tests! 🤯🤪

It was very tempting to start with refactors right away during writing the tests 😅 ...in some cases, I couldn't resist. So now I need to go back to my playground and test out if it all still works as intended. Manual tests are still passing 🥳

Bonus found a bug: Invalid selectors were not being discarded on initialization! It's already starting to pay off :)

@daun sorry for the huge PR, this is a review nightmare. But oh well, who cares really, as long as everything keeps working, right?

Todo

Checks

hirasso commented 12 months ago

Alright, ready for review :)