Uh oh!
There was an error while loading. Please reload this page.
test: added common.mustCallAtLeast - #12935
Conversation
refack
commented
May 9, 2017
CI: https://ci.nodejs.org/job/node-test-commit/9765/ |
There was a problem hiding this comment.
Can you undo this block of changes.
There was a problem hiding this comment.
the JSDocs?
It's usefull for people with IDEs that can parse these (VSCode / Webstorm)
There was a problem hiding this comment.
Other than lib/punycode.js which is vendored, there are only 9 @param matches in all of lib, src, and test. It's more consistent to drop them.
There was a problem hiding this comment.
This code should live in test/parallel/test-common.js I think.
cjihrig
commented
May 9, 2017
I think this needs a documentation update. |
refack
commented
May 9, 2017
Docs added, nit's addressed. @cjihrig I'd rather keep the JSDocs, unless you have a strong objection. |
cjihrig
commented
May 9, 2017
I wouldn't say strong objection, but definitely -1. |
refack
commented
May 9, 2017
Gone. |
Fishrock123
commented
May 9, 2017
Could you point to somewhere that this would be better suited for rather than the explicit number of calls? |
Fishrock123
commented
May 9, 2017
I generally think this is a bad idea because if something is being called more times than you expect you've probably got a bug. |
refack
commented
May 9, 2017
|
refack
commented
May 9, 2017
I tend to agree, but some things are either OS dependent or non deterministic. In those cases we tend to skip the |
-1 I don't think it is a good idea to reuse the same parameter (or even the same function) for this. |
jasnell
commented
May 9, 2017
@Fishrock123 ... this came up with regards to adding @mscdex ... the other option I had in mind was a |
mscdex
commented
May 9, 2017
@jasnell I would much prefer a separate method so that the intention is clear. |
refack
commented
May 9, 2017
Trott
left a comment
There was a problem hiding this comment.
-0 from me. I dislike magic values. I prefer that things in common have simple, self-explanatory, and intuitively obvious interfaces. This adds more cognitive overhead, especially for newcomers.
There was a problem hiding this comment.
Nit: This documentation change results in a confusing run-on sentence:
If the returned function has not been called exactly
expectednumber of times, or at least once ifexpected === '+', when the test is complete, then the test will fail.
Would be better as something like:
If the returned function has not been called exactly
expectednumber of times when the test is complete, then the test will fail. Ifexpected is'+'`, then the test must run at least once.
gibfahn
commented
May 9, 2017
Trott
commented
May 9, 2017
Eh, still pretty +/-0 on it. I think there's enough API surface area in Moreover, I'm not really sure this is solving a very common problem. I imagine it's mostly for But if others feel this has big value, I won't stop it. |
refack
commented
May 9, 2017
Replace magic '+' with |
expectedcommon.mustCallAtLeastrefack
commented
May 9, 2017
P.S. why don't we adopt something like |
Trott
commented
May 10, 2017
Biggest reason is probably because no one's bothered to do it yet. That said, a PR adding sinon very well might not get accepted. Speaking only for myself, I have grown wary of things that raise the barrier to entry for people working on tests. So to the extent that we avoid extra tools and unneeded abstractions in the Others in @nodejs/testing might have other opinions. |
refack
commented
May 19, 2017
Pre land CI: https://ci.nodejs.org/job/node-test-commit/10013/ |
refack
commented
May 19, 2017
landed in fccc0bf |
MylesBorins
commented
Jul 17, 2017
Should this land on v6.x? |
refack
commented
Jul 17, 2017
Sure. It's a |
refack
commented
Jul 17, 2017
#14327 depends on this |
PR-URL: #12935 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #12935 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
added
common.mustCallAtLeastfor calling more thanminimumtimes.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test