-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add only
modifier to describe
, it
and test
methods
#767
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #767 +/- ##
==========================================
+ Coverage 99.08% 99.12% +0.04%
==========================================
Files 36 36
Lines 1742 1824 +82
Branches 10 10
==========================================
+ Hits 1726 1808 +82
Misses 8 8
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
- Only tests using `.only` will be run. This applies to `describe`, `it` and `test` at the same time. | ||
- If a common `describe` has a `it.only` in its scope, for example, the `it.only` will not be reached (see [**`--itOnly`**](#--itonly)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below it is documented that --only
is the same as --describeOnly --itOnly
. Hm.. Looks like these are contradicting statements. Or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, did you consider: --only=it
, --only=test
, --only=describe,test
? The jump from --only
to --describeOnly
does not feel intuitive. If I want the only
feature, makes me think of typing --only
first and optionally adding something to it. Or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another aspect, what happens with the after/before hooks? And is the code contain within describe()
executed at some point? Or how? Not clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--only=it
,--only=test
,--only=describe,test
That sounds interesting.
Below it is documented that
--only
is the same as--describeOnly --itOnly
. Hm.. Looks like these are contradicting statements. Or?
I'm not sure I understand 😅
Another aspect, what happens with the after/before hooks? And is the code contain within
describe()
executed at some point? Or how? Not clear.
Everything should work exactly the same with or without the .only
. The .only
just calls the base it
or describe
methods, for example:
poku/src/modules/helpers/modifiers.ts
Lines 87 to 88 in 8dcce80
if (typeof messageOrCb === 'string' && cb) return itBase(messageOrCb, cb); | |
if (typeof messageOrCb === 'function') return itBase(messageOrCb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is “exactly the same”? So the describe()
code is always executed? Or only with --testOnly
, but not with --describeOnly
? And what about --only
, all describe()
code with be executed, or none, or some?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more: behaviour example of
.only
within nesteddescribe
blocks is missing.describe
>describe.only
>test
. Is thisdescribe.only
executed with--only=describe
? Or the parentdescribe
gets skipped?
If the first describe
is skipped, everything within its scope/context will be skipped too 🙋🏻♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying it out:
import { describe, test } from "poku";
describe(() => {
describe.only(() => {
test("one", () => {
//
});
});
});
test("two", () => {
//
});
--only=describe
runs"two"
. The command is aboutonly
anddescribe
, but it runs a test that does not haveonly
and is not within adescribe
. Puzzling? Isn’t it?
import { describe, test } from "poku";
describe.only(() => {
test("one", () => {
//
});
});
test("two", () => {
//
});
--only
runs nothing. Hm.. (First I was looking for my mistake. Now I think this is by design. Perhaps? Or is this a bug? Hm..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah.. I see. Second example is my mistake. To make it work as I expect, if this pattern would be implemented:
import { test } from "poku";
test.only((t) => {
t.test("one", () => {
//
});
});
test("two", () => {
//
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Puzzling? Isn’t it?
At this point, it's important to consider that --only=describe
is different from "mapping the describe
methods", but rather "enabling .only
for the describe
methods". To use .only
for test
and it
, it's necessary to enable it for them.
- Now I think this is by design
Yes, the describe
is executed, but the "one" don't, since it doesn't use the .only
with --only
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The limitations of not mapping the tests to the .only
case while trying to bring about a similar behavior to the usual one were holding me back both technically and creatively.
The idea of switching on and off and the concept of "enabling", helped me to reconcile a different approach without losing the idea of JavaScript syntax.
Closes #722.
poku
runnerpoku
runnerdescribe
+describe.only
describe.only
+describe.only
it
+it.only
it.only
+it.only
describe.only
+it
describe.only
+it.only
describe
+it.only
.only
without--only
Experimental usage
--only
.only
will be run. This applies todescribe
,it
andtest
.describe
has ait.only
in its scope, theit.only
will not be reached.--describeOnly
describe
tests using.only
will be run.--itOnly
or--testOnly
(alias):it
andtest
tests using.only
will be run.