Turn Bad Code into Good Code (Javascript, TypeScript, Node, Jest, unit Testing)

preview_player
Показать описание
Using Jest unit testing to help refactor some poorly written javascript code into better javascript code.

00:00 Intro
5:37 - Writing Unit Tests using Jest
16:56 - Refactoring the Code

------------

Рекомендации по теме
Комментарии
Автор

Not all heroes wear capes ;)! No, but seriously I'm starting to binge on your videos and I feel like you're one of the few yt lecturers who is so practical and actually helpful. I'm at the stage of my learning, where I struggle precisely with writing more readable, maintainable code and proper tests and you manage to choose example(s) easy enough to follow, but complex enough to explain the issues. I always found the other yt tutorials lacking the comparisons between good and bad code/ good and bad practice. It always seemed like something you can only improve if you're getting some sort of feedback on your program irl. I look at my code and I am fully aware it looks kinda all over the place, some functions are way too long, but what do I do exactly, , that's the question. It's hard to keep track of all the things you need to do >in the first place<, when starting to write a more complex app, so you don't end up dreading the smallest refactor afterwards, because everything starts to get convoluted and messy, and just breaks x'd. So thank you so much, really, you're great!

Sapphiamur
Автор

Beautiful and helpful. You thought we were going to lose interest but we were impressed.

ravenMK_
Автор

Great video! Testing is so important, I've been trying to include more testing in my videos.

TomDoesTech
Автор

Thank you for breaking this down so nicely and making it easy to understand. Completely agree with what Sapphiamur said below - Not all heroes wear capes.

iyergh
Автор

never watched your video before, but this one made me surprised. A lot of important things in just one video. Subscribed!

robiparvez
Автор

Everyone keeps telling me to learn testing, so I’m super thankful for this vid :)

shawn.builds
Автор

Wow it was a really helpful video, especially the testing part since i was always skeptical of testing and just trusted my eyes and the console logs😅. Could you please also make a video about file or folder structures? Whenever i visit an open source repo, they have folders like utils, lib etc. I know it differs based on each project but I think it would be helpful to have a middle ground on where we should put our files and why the folders are named as such.

bandekhoda
Автор

I love you content man, I am a junior developer and your videos are gold for my. This video has helped me more than many courses, thank you so much.

ivansaidflores
Автор

28:00 I don't get this black and white thinking when it comes to writing comments. It doesn't automatically mean your code is bad if you use them. It always depends on the context.

Toopa
Автор

The reason you shouldn't export a private function to test it is so you avoid making refactor a burden.
If you export "implementation details"; there's high change this function could just be reused in other places as a utility function for me, and it might be the case for your "getAverageCourseGrade", it could just have been less aware of it's context, and just have been "getAverage(numbers: number): number"

nirrepluap
Автор

I wish to see more videos like this from you. Nice job.

ksisioO
Автор

Hi Cody, Thanks for an excellent tutorial. I think you could have split this into a series given the breadth of material you covered but well done.
I have been a Software Engineer for many years and am horrified but the number of YouTube videos I see stating testing (and specifically unit testing) is not important, unjustifiably time consuming and costly.
I fully support your comments that (to paraphrase) you cannot refactor a unit safely without having a unit test in place, and a unit is not finished unless you have a unit test to confirm it does what you (the developer) expected.
On that last point; that is why I prefer to call them unit proofs rather than unit tests just so developers don't think they can leave it to the test team to create them.

gilmoretj
Автор

nice video to motivate me to write clean code

集中-lm
Автор

Exactly what developers should watching

RdozeTV
Автор

omg and testing and refactoring so much information, thank you

gwdfdek
Автор

Dude, your videos are on fire! 🔥It almost makes me want to switch to full on TypeScript already over vanilla JS.

lpdrummerboy
Автор

thank you so much this is the content i m looking for ♥

mumustemend
Автор

That is actually really helpful. I'm a typescript noob, and you pointed all the problems i definitely still have in my code.

LwPressure
Автор

I have a question, when you removed the data to the test file, where did you get data to test the code after being removed?

NuNagames-zffm
Автор

This content is so great. I'm a mid node.js dev, i wish i knew this channel when i was getting started. Finally understood the purpose of testing :D

partiid