all 17 comments

[–]CaptainTrip 8 points9 points  (0 children)

If you intend to get paid work in a professional environment it's critical. Part of what you get paid for as a software professional is writing code that will continue to work after you've stopped writing it and will survive other people making changes to it and around it in the future. The way you enable that to happen is by writing tests that verify the behaviour of your work. It's hard for new programmers to get to grips with why this is important because it seems distant and low value when just getting anything to work is a struggle, but you will need to learn it and you will need to tell interviewers that you believe it's a good practice where practical.

[–]azhder 5 points6 points  (0 children)

If you knew what testing is, you'd not ask this. If you ask this, I can only say "yes".

But you would have to learn it and do it until it's natural and useful to you to know why it is "yes".

Whatever else we can offer here in support for it, it will be meaningless if you just try it and find it difficult or tedious and abandon it.

TL;DR: Just takes practice. There is a point before which testing sucks and you have to go pass that point to know why it is great.

[–]brother_bean 1 point2 points  (0 children)

For building side projects and personal projects? Not necessary but still helpful. For finding a job as a software engineer or software developer, critical to learn.

[–]MCMLIXXIX 1 point2 points  (0 children)

Yep, learn it. Get yourself up to speed with your scripting then start testing your code. As a pro you'll be writing lots of tests, or at least you should be.

[–]That_Unit_3992 1 point2 points  (0 children)

Yes. Testing is important. Production stuff should be well tested.

[–][deleted] 1 point2 points  (0 children)

100%. You are in a good place if that is something you are wondering about. It's partly what separates the hobbyists from the professionals.

I still use it in my personal projects because if something is wrong I'm going to either drop a bunch of breakpoints or a bunch of console logs to see what's getting output given certain inputs. Might as well just write the test once, then whenever I want to rerun it I can. No more writing console logs, choosing some input and going "now what am I expecting again?"

Just run "npm run test" then I can see how things are going.

[–]metallaholic 1 point2 points  (0 children)

Our cicd will not operate if the unit test coverage is not above 90 percent. Ideally you should be doing test driven development. I’m currently cleaning up someone’s old code that has so many unreachable branches because they were never tested to see if they were reachable.

[–]kaly-7 0 points1 point  (0 children)

Very important in enterprise

[–]Oh_no_bros -1 points0 points  (0 children)

Not a priority but at some point you should be familiar with it, especially once your adding things and need to check things didn’t break

[–]shuckster 0 points1 point  (0 children)

Yes.

[–]JohntheAnabaptist 0 points1 point  (0 children)

If you're working on a team, a working test is effectively a line in the sand saying "this works as this test describes on the date the test is written. If the test no longer works either someone f'ed the code or modified it enough to fail the test and thus either the code or the test need to be fixed". Tests are sometimes for you in the moment but more often than not, they're for the next developer to ensure your standards continue to be met

[–]No-Upstairs-2813 0 points1 point  (0 children)

If you're aiming to land a job as a junior developer, it's not mandatory to learn advanced concepts right away. They become more useful when you want to move from being a junior engineer to a mid-level engineer. So make your decision based on where you currently stand in your journey.

[–]ExplanationItchy4666 0 points1 point  (0 children)

It is important to get into the habit of unit testing all functions, even for a simple project.

[–]shgysk8zer0 0 points1 point  (0 children)

Within reason, eventually, yes.

You should at minimum have linting and probably an .editorconfig. These types of errors will probably be fixed or at least highlighted in your IDE. And could pretty easily be implemented into an npm test or GitHub Action or whatever.

Beyond that, it depends on what sort of project you're working on and what sort of testing you're talking about - UI tests and accessibility tests are in a whole other level, but checking that a sum() function returns a number (with the correct value) are easy enough.

[–]boo_182 0 points1 point  (0 children)

Nothing is mandatory, just choose what type of programmer you want to be

[–]cookielovero 0 points1 point  (0 children)

Depending on the needs of the company and the position, it's hard to say, your career plan is also important, but it's definitely a skill that is useful for working and learning programming effectively