-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
test_runner: make skip/todo/expectFailure use JS truthiness #62346
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
Open
VaishnavIUpadyaya
wants to merge
6
commits into
nodejs:main
Choose a base branch
from
VaishnavIUpadyaya:test-runner-truthy-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+8
−2
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0a28ef2
test_runner: make skip/todo/expectFailure use JS truthiness (#61815)
VaishnavIUpadyaya c96d866
test_runner:make skip/todo/expectFailure use JS truthiness (#61815)
VaishnavIUpadyaya 58be01d
test: use common.mustCall() for skip empty string test
VaishnavIUpadyaya 56ab67a
test: add newline at end of file
VaishnavIUpadyaya 6014f0a
style: use !!skip instead of Boolean(skip)
VaishnavIUpadyaya 814ea72
style: remove unused Boolean from primordials
VaishnavIUpadyaya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| 'use strict'; | ||
|
|
||
| const common = require('../common'); | ||
| const { test } = require('node:test'); | ||
|
|
||
| test('skip option empty string should not skip', { skip: '' }, common.mustCall()); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why not? this seems wrong to me
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.
I would fix the docs, not the implementation - it seems for correct
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.
@atlowChemi @JakobJingleheimer WDYT?
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.
I can see why both behaviors would make sense.
Do we know what other test runners do?
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.
Thanks for the feedback!
I based this change on the docs describing these options as "truthy", so I assumed an empty string ('') should be treated as false.
That said, I see your point — changing the implementation could introduce unintended breaking behavior. Updating the docs to reflect the current behavior sounds reasonable.
I'm happy to update this PR to focus on the docs instead. Let me know what you prefer!
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.
I think there's a decent chance an empty string is an accident, but the user could be relying on something that outputs a potentially empty string.
I think in general, truthy/falsy makes sense; since that includes an empty string, yeah.
I'm not sure what others do. I'll take a look this evening.
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.
It looks like jest and mocha do not have this—they expose them only as methods like
test.only('…')andtest.skip('…').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.
tape has this, and uses truthiness.