🔥 (#164) Unit Testing in Nuxt
Hey all! I've got some great tips for you this week on unit testing in Nuxt. In case you missed it, the latest episode of Deja Vue was on Nuxt server components with Julien Huang, another member of the Nuxt team. The episode covers a whole bunch of interesting topics, including:
and so much more! Find the episode on your favourite platform here. If you have any suggestions for topics or guests you'd like to hear from, let me know! Just reply to this email. Now, on to the tips! — Michael Vue Tips Collection 2Maybe you just want to stay on top of the latest features, remind yourself of interesting things Vue can do, and get daily inspiration. Vue Tips Collection is a beautiful book of 118 concise tips, as well as a daily email to get your creative juices flowing. 🔥 Mock Any Import in NuxtOne handy helper method in It's a convenience method to make it easier to mock anything that Nuxt would normally auto-import: 🔥 Easy Unit Testing in NuxtFor your unit tests, You can also add a special comment at the top of the file: Or enable the environment for all Vitest tests in your config: 🔥 Mount Components When Testing in NuxtWhen writing unit tests, you have access to a bunch of helper methods. One super useful one is You're also able to mount your app at a specific route, by passing in the App component and a route: 📜 Helpful Patterns I Use in VueAlthough I disagree with using custom elements to get a flatter component hierarchy, Brennan has a bunch of useful tips and patterns in this article. I use the loading state one all the time. Check it out here: Helpful Patterns I Use in Vue 💬 The Code You Don't Write"The code you write makes you a programmer. The code you delete makes you a good one. The code you don't have to write makes you a great one." — Mario Fusco 🧠 Spaced-repetition: Writable Computed RefsThe best way to commit something to long-term memory is to periodically review it, gradually increasing the time between reviews 👨🔬 Actually remembering these tips is much more useful than just a quick distraction, so here's a tip from a couple weeks ago to jog your memory. Computed refs are cool and all, but did you know you can create writable computed refs?
|
评论
发表评论