René's URL Explorer Experiment


Title: Method to run Node test-runner ignoring/rejecting any `test.only`/`test(..., { only: true }, ...` filters · Issue #60917 · nodejs/node · GitHub

Open Graph Title: Method to run Node test-runner ignoring/rejecting any `test.only`/`test(..., { only: true }, ...` filters · Issue #60917 · nodejs/node

X Title: Method to run Node test-runner ignoring/rejecting any `test.only`/`test(..., { only: true }, ...` filters · Issue #60917 · nodejs/node

Description: What is the problem this feature will solve? Since the resolution of #47945, node --test will automatically filter tests which are not marked .only, if any test/suite is marked with only: true AND --test-only is passed a command line fla...

Open Graph Description: What is the problem this feature will solve? Since the resolution of #47945, node --test will automatically filter tests which are not marked .only, if any test/suite is marked with only: true AND ...

X Description: What is the problem this feature will solve? Since the resolution of #47945, node --test will automatically filter tests which are not marked .only, if any test/suite is marked with only: true AND ...

Opengraph URL: https://github.com/nodejs/node/issues/60917

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Method to run Node test-runner ignoring/rejecting any `test.only`/`test(..., { only: true }, ...` filters","articleBody":"### What is the problem this feature will solve?\n\nSince the resolution of #47945, `node --test`  will automatically filter tests which are not marked `.only`, if\n\n* any test/suite is marked with `only: true`\n* AND \n    * `--test-only` is passed a command line flag\n    * OR process-isolation is disabled by `--test-isolation=none`\n\nIn addition, since #51383, _filtered_ tests/suites are not passed to test-reporters at all.\n\nWhen developing locally, this is convenient. However, when running tests in CI, it means _there is no way to detect whether or not test-filtering is occurring_ when `--test-isolation=none`. This means it's possible for someone to accidentally push a`.only` call, which will silently disable the rest of the tests.\n\nIt _appears_ that this logic is defined here:\n\n* 24 (current LTS): https://github.com/nodejs/node/blob/v24.x/lib/internal/test_runner/harness.js#L47\n* current `main`: https://github.com/nodejs/node/blame/f9f343fb8dda773b749db4dee00704f8bbe79c19/lib/internal/test_runner/harness.js#L47\n\nwhich forces `isFilteringByOnly` to be `true` when `globalOptions.isolation === 'process' || process.env.NODE_TEST_CONTEXT` is `false` (note that this presents a partial workaround for Node 24, but not Node 22 which is still supported until April 2027)\n\n### What is the feature you are proposing to solve the problem?\n\nA command-line option that allows running tests in a way that detects accidental inclusions of `{ only: true }` / `it.only` / `describe.only` / etc.\n\n#### additional  `--test-only` flag features\n\nI think the simplest & best option would be to introduce 2 new possible values for the `--test-only` flag:\n\n* `--test-only` / `--test-only=true`: The current behavior\n* `--test-only=false`:\n    * Runs all tests; even if some other tests are marked with `{ only: true }`, tests are NOT filtered out for having `{ only: false }`.\n    * Other filtering (from name patterns) still occurs as normal.\n* `--test-only=error`:\n   * I think there are several reasonable semantics for this mode, which I don't have strong opinions between:\n      * Should it generate an error...\n         * ...when the tests are collected?\n         * ...when the tests are run?\n         * ...after the tests are run?\n      * Should it report an error...\n          * ....if any test/suite specified `{ only: true }`?\n          * ...if a test is _filtered_ because it _didn't_ specify `{ only: true }`?\n          * (The difference  is only in test-suites that mark EVERY test as `.only` so the difference is probably negligible)\n      * Should it run the tests as normal?\n         * Should it report an error for filtered/`only` tests _in the stead of_ that test?\n         * Or should it report a separate \"sub test\" regarding the unexpected use of `only`?\n         * Should it report the unexpected use of `only` overall (either before/after running all tests) or only at the end/beginning as a count of filtered tests only?\n\n#### additional test-reporter events\n\nWhile I think `--test-only=error`'s behavior would generally be desirable to essentially all Node programs using the `node:test` runner when running tests in CI, configuration for it in different test-reporters may become complicated over time.\n\nA more customizable alternative would be to emit an additional event for filtered tests, which indicates what caused the test to be filtered. Handling of this event could be added to either custom-reporters, a new build-in test-reporter, or the existing test-reporters, to emit an error in the case that filtered test-cases are undesirable.\n\n\n### What alternatives have you considered?\n\nFrom reading the documentation of [test runners](https://nodejs.org/api/test.html) and the [command-line arguments](https://nodejs.org/api/cli.html), it seems the current version of Node does not have a way to cause this kind of behavior when running the test runner via the `node --test` CLI.\n\nBecause filtered tests do not emit events to test-reporters (#51383), a custom test-reporter cannot be used to detect this.\n\nI can see several ways to workaround this right now:\n\n#### lint against `.only` / `{ only: true }` invocations of `node:test`\n\nThis is probably the most straightforward, but it is very complex, and cannot be complete. It cannot detect non-textual references to these, for example, in the (admittedly undesirable) case these flags are computed dynamically, or tests are imported from another library.\n\n#### (Node 24+) use the undocumented `NODE_TEST_CONTEXT=_` workaround\n\nIt seems this parameter is used for process-isolation; however, when not using process-isolation, it also triggers the branch that allows the `isFilteringByOnly` to default to `false`/`undefined` in Node 24+.\n\nThis seems likely unintentional and the behavior is [documented to be unpredictable](https://nodejs.org/api/cli.html#node_test_contextvalue)\n\nThis workaround does not support the `--test-only=error` use case.\n\n#### enable test-isolation\n\nEnabling process isolation for tests will effectively disable the `{ only: true }` filtering logic\n\nThis workaround does not support the `--test-only=error` use case.\n\n#### introduce a \"canary\" test to detect filtering\n\nTo ensure tests aren't filtered, I can introduce a dummy `test(\"ensure not filtered\", () => {});` and ensure that this test is reported.\n\nThis mostly works, but it is indirect and incomplete. For example, if a `.only` call is added to the canary test, any `.only` calls become allowed anywhere else.\n\n#### manually construct `run` tests instead of using the `node --test` CLI\n\nWhile the CLI does not seem to currently support the proposed `--test-only=false` flag, the  `run` method exposed in `node:test` does:\n\n```js\n// Only seems to work in Node 22?\nimport nodeTest from \"node:test\";\nimport { spec } from \"node:test/reporters\";\n\nnodeTest\n  .run({\n    concurrency: false,\n    globPatterns: [\"dist/**/*.spec.js\"],\n    isolation: \"none\",\n    coverage: false,\n    /** Milliseconds */\n    timeout: 90_000,\n  })\n  .compose(spec)\n  .pipe(process.stdout);\n```\n\nThis workaround does not appear to support the `--test-only=error` use case, although it may be possible","author":{"url":"https://github.com/curtisfennergivery","@type":"Person","name":"curtisfennergivery"},"datePublished":"2025-12-01T07:49:34Z","url":"https://github.com/nodejs/node/issues/60917"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:96d0618c-f68a-be44-a8d5-39d3a1e39037
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id85B2:2E7DFB:2C1BD98:3A4FCF9:6B033857
html-safe-nonce4a95075480aae0bf4dce34fa2b52580e50136e96dd3d7c77ac07473cb06790ed
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NUIyOjJFN0RGQjoyQzFCRDk4OjNBNEZDRjk6NkIwMzM4NTciLCJ2aXNpdG9yX2lkIjoiNjYyMDkzNDQ2MjE3MzgyMTAxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaca94ffeb3a3c3124002e81dc4b8a389a06e5f108de9a1754901231b5eebb512ea
hovercard-subject-tagissue:3679718112
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/60917/issue_layout
twitter:imagehttps://opengraph.githubassets.com/8a92f2b524adf7e48550ae96e28a13a8f364c022a4cdd205b16113df52336017/nodejs/node/issues/60917
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8a92f2b524adf7e48550ae96e28a13a8f364c022a4cdd205b16113df52336017/nodejs/node/issues/60917
og:image:altWhat is the problem this feature will solve? Since the resolution of #47945, node --test will automatically filter tests which are not marked .only, if any test/suite is marked with only: true AND ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecurtisfennergivery
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/60917#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F60917
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F60917
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/60917
Reloadhttps://github.com/nodejs/node/issues/60917
Reloadhttps://github.com/nodejs/node/issues/60917
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues637 (637)https://github.com/nodejs/node/issues
Pull requests668 (668)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/insights
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/60917
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/60917
Method to run Node test-runner ignoring/rejecting any test.only/test(..., { only: true }, ... filtershttps://github.com/nodejs/node/issues/60917#top
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stale%22
test_runnerIssues and PRs related to the test runner subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22test_runner%22
https://github.com/curtisfennergivery
curtisfennergiveryhttps://github.com/curtisfennergivery
on Dec 1, 2025https://github.com/nodejs/node/issues/60917#issue-3679718112
#47945https://github.com/nodejs/node/issues/47945
#51383https://github.com/nodejs/node/issues/51383
https://github.com/nodejs/node/blob/v24.x/lib/internal/test_runner/harness.js#L47https://github.com/nodejs/node/blob/v24.x/lib/internal/test_runner/harness.js#L47
https://github.com/nodejs/node/blame/f9f343fb8dda773b749db4dee00704f8bbe79c19/lib/internal/test_runner/harness.js#L47https://github.com/nodejs/node/blame/f9f343fb8dda773b749db4dee00704f8bbe79c19/lib/internal/test_runner/harness.js#L47
test runnershttps://nodejs.org/api/test.html
command-line argumentshttps://nodejs.org/api/cli.html
#51383https://github.com/nodejs/node/issues/51383
documented to be unpredictablehttps://nodejs.org/api/cli.html#node_test_contextvalue
curtisfennergiveryhttps://github.com/curtisfennergivery
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
on Dec 1, 2025https://github.com/nodejs/node/issues/60917#event-21268383228
github-project-automationhttps://github.com/apps/github-project-automation
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
on Dec 1, 2025https://github.com/nodejs/node/issues/60917
github-project-automationhttps://github.com/apps/github-project-automation
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
on Dec 1, 2025https://github.com/nodejs/node/issues/60917#event-21268385747
curtisfennergiveryhttps://github.com/curtisfennergivery
on Dec 1, 2025https://github.com/nodejs/node/issues/60917#event-21268386709
curtisfennergiveryhttps://github.com/curtisfennergivery
on Dec 1, 2025https://github.com/nodejs/node/issues/60917#event-21268801880
pmarchinihttps://github.com/pmarchini
test_runnerIssues and PRs related to the test runner subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22test_runner%22
on Dec 2, 2025https://github.com/nodejs/node/issues/60917#event-21316064961
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on Jul 1, 2026https://github.com/nodejs/node/issues/60917#issuecomment-4849540632
GitHub Actionshttps://help.github.com/en/actions
github-actionshttps://github.com/apps/github-actions
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stale%22
on Jul 1, 2026https://github.com/nodejs/node/issues/60917#event-27406006549
https://github.com/curtisfennergivery
curtisfennergiveryhttps://github.com/curtisfennergivery
on Jul 1, 2026https://github.com/nodejs/node/issues/60917#issuecomment-4850077888
Node 26.x CLI docshttps://nodejs.org/docs/latest-v26.x/api/cli.html#--test-only
Node 26.x node:test Test Runn docshttps://nodejs.org/docs/latest-v26.x/api/test.html#only-tests
--test-onlyhttps://nodejs.org/docs/latest-v26.x/api/cli.html#--test-only
github-actionshttps://github.com/apps/github-actions
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stale%22
on Jul 2, 2026https://github.com/nodejs/node/issues/60917#event-27456929377
https://github.com/davidthornton
davidthorntonhttps://github.com/davidthornton
on Jul 11, 2026https://github.com/nodejs/node/issues/60917#issuecomment-4942587779
joao-oliveira-softtorhttps://github.com/joao-oliveira-softtor
on Oct 8, 2026https://github.com/nodejs/node/issues/60917#event-32741763447
test_runner: add option to forbid exclusive testshttps://github.com/joao-oliveira-softtor/node/commit/1cff51ccabc7490339831223e15b133a7ca2ccfd
1cff51chttps://github.com/joao-oliveira-softtor/node/commit/1cff51ccabc7490339831223e15b133a7ca2ccfd
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on Oct 10, 2026https://github.com/nodejs/node/issues/60917#issuecomment-6092245653
GitHub Actionshttps://help.github.com/en/actions
github-actionshttps://github.com/apps/github-actions
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stale%22
on Oct 10, 2026https://github.com/nodejs/node/issues/60917#event-32920478322
nodejs-github-bothttps://github.com/nodejs-github-bot
on Oct 23, 2026https://github.com/nodejs/node/issues/60917#event-34026870572
test_runner: add option to forbid exclusive testshttps://github.com/nodejs/node/commit/45b6626457e233fe0f907448ac21681a472b04f5
45b6626https://github.com/nodejs/node/commit/45b6626457e233fe0f907448ac21681a472b04f5
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on Nov 10, 2026https://github.com/nodejs/node/issues/60917#issuecomment-6755985770
GitHub Actionshttps://help.github.com/en/actions
github-actionshttps://github.com/apps/github-actions
not plannedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Anot-planned
on Nov 10, 2026https://github.com/nodejs/node/issues/60917#event-35632268751
aduh95https://github.com/aduh95
on Nov 17, 2026https://github.com/nodejs/node/issues/60917#event-36412346760
test_runner: add option to forbid exclusive testshttps://github.com/nodejs/node/commit/02342352f2bc989c0a7249b578d33b41e0b172b7
0234235https://github.com/nodejs/node/commit/02342352f2bc989c0a7249b578d33b41e0b172b7
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/60917
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/60917
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stale%22
test_runnerIssues and PRs related to the test runner subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22test_runner%22
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.