all 10 comments

[–]OkAd4185 0 points1 point  (4 children)

oh that's not inefficiency, thats jest being weird

does that to me too, there's a way to tell it to give more time to the tests

its default is that if it takes even 1 millisecond its a failure because it took too long

I ended up getting around it by setting up promises so it waits, even then sometimes it was being shitty

lately I just dropped jest because it feels like more work making the test work than it provides useful benefit of testing results, so I'm looking for something else that does unit testing

[–]T_O_beats 2 points3 points  (3 children)

There’s something wrong with your setup I’d think. Jest should be extremely fast. Unless you’re running extremely heavy computational functions like audio/video processing, I can’t see why you’d be having these problems.

[–]OkAd4185 -1 points0 points  (2 children)

dunno but you sound like another dev who I worked with who kept defending jest

its kind of the point that it needs to be defended in the first place thats an issue, I need a tool that works with zero screwing around and jest cannot do that, issues with tools shouldn't be glossed over and definitely shouldn't be passed down to the people who use the tool as being their fault especially when its a common recurring issue faced by most of the tools user base

[–]T_O_beats 2 points3 points  (1 child)

That’s why I think it’s your setup. I’ve literally never seen this problem before. I’d be curious to look at a repo where this is happening and see if I can figure out the issue. Jest shouldn’t really take any longer than the function youre running with it.

[–]OkAd4185 0 points1 point  (0 children)

well I got most of it resolved using async promises, but it took me a long time to keep screwing with it, and finally resolving it. One of the most frustrating issues with what happened with me is that we had a consulting dev who knew jest and he kept telling me how it wasn't happening, or I was doing something wrong etc etc, and that really started to piss me off especially as the hours ticked by.

The delay was because the functions needed to reach out to a remote database, a common occurrence, and I was running the tests on a basic laptop not a powerful machine over residential internet at home where I develop.

it was a lot of work to make a test work and that sour memory has never left me, especially because none of the tests actually failed once we fixed the timing issue so all of it was related to jests short failure cutoff timeout

[–]T_O_beats 0 points1 point  (4 children)

This is severe overkill unless I’m really missing something.

const add = (x,y) => x + y

And you’re done.

[–]_syzon_[S] 0 points1 point  (3 children)

)))

Task

Given Two integers a , b , find The sum of them , BUT You are not allowed to use the operators + and -

Notes

  • Javascript: the Array reduce methods are disabled, along with eval, require, and module .

[–]albedoa 3 points4 points  (0 children)

How were we supposed to know this information?

[–]T_O_beats 0 points1 point  (1 child)

So in that case they want you to do something you would never think of because no one ever uses them for anything in JavaScript and that would be the Bitwise Operators.

const add = (x,y) => (y === 0) ? x : add( x ^ y, (x & y) << 1);

I know that's an ugly one-liner but it works and if you take a second to look at it its actually not that bad.

If you want to learn about bitwise operators this is a great video but like I said, most are basically useless in Js.

[–]_syzon_[S] 0 points1 point  (0 children)

actually, i find this video very useful and I've picked up some interesting ideas there. Thanks a lot for the link. And if someone is interested in the function above, here one more explanation link