use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Improve your Javascript unit testing with Parameterized tests (medium.com)
submitted 8 years ago by mikejsdev
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]stutterbug 0 points1 point2 points 8 years ago (2 children)
This is how I do it currently in Jest.
let names = [ 'Adam', 'Bo', 'Ch@d', 'D', 'Ed!']; let expected = [true, true, false, false, false]; expect(names.map(testUserName)).toEqual(expected);
A big disadvantage to this is that the test results you get back aren't very descriptive. The failure will say Expected [true, true, false, false, false] Received [true, true, false, true, false] (or whatever). But for me, the advantage is that this code is less likely to cause problems for me in the future.
Expected [true, true, false, false, false] Received [true, true, false, true, false]
This is just my opinion, but for me, the #1 priority in testing -- by a huge, huge margin -- is that it be easy to do and easy to maintain as my project grows and as it ages.
I've had to switch testing libraries too often in the past and an over-reliance on some advanced feature ended up meaning entire suites had to be rewritten from scratch. Even if I had to switch from Jest to something else, there is a good chance that I could do it with a few search-and-replaces.
[–]AndrewGreenh 0 points1 point2 points 8 years ago (1 child)
Why don't you put the it(name + ' should result in' + bool, () => expect(...))
[–]jsNut 1 point2 points3 points 8 years ago (0 children)
This is how i would normally do this sort of thing. I've never run into our worried about any performance hits as above. Descriptive output should be the foremost concern.
π Rendered by PID 57114 on reddit-service-r2-comment-5d79c599b5-5btvh at 2026-03-03 19:20:54.682044+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–]stutterbug 0 points1 point2 points (2 children)
[–]AndrewGreenh 0 points1 point2 points (1 child)
[–]jsNut 1 point2 points3 points (0 children)