Skip to content

Revert "test_runner: change ts default glob" #58202

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

Merged

Conversation

theoludwig
Copy link
Contributor

TypeScript files glob for the test runner was added in #55081, and then changed in #57359. With this PR, I would like that we revert #57359, or at least open the discussion. Great default, and a runtime which just "work out of the box" is important, that's why changing the defaults matter.

Why should TypeScript files have different globs than JavaScript files?
It was already suggested that for v24.0.0, we remove this restriction of the test folder: #57359 (comment).

As we are approaching the stabilization of the TypeScript strip types feature, it is now or "never" (or only able to change that in semver major versions) to change the defaults, since it is still experimental for now, there is still time to do it.

Today, I wanted to try Node.js v24.0.0, and since v24 obviously include everything from v23 and v23 includes #57359, I was surprised that my tests were ignored (upgrading from v22).

#57359 (comment)

I think the issue is that people keep their test.ts in the src folder and transpile them, so they will be executed twice. Once node v20 goes EOL we can be more lax and include other patterns

Why should people transpile test files, if it's possible to run them without transpiling thanks to that strip types feature? (I indeed keep my TypeScript files under a src folder).

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels May 6, 2025
@theoludwig
Copy link
Contributor Author

What do you think? @JakobJingleheimer, @marco-ippolito

Copy link

codecov bot commented May 7, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.12%. Comparing base (e38ce27) to head (95d88b8).
Report is 101 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/test_runner/utils.js 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58202      +/-   ##
==========================================
- Coverage   90.14%   90.12%   -0.02%     
==========================================
  Files         629      629              
  Lines      186634   186634              
  Branches    36616    36621       +5     
==========================================
- Hits       168236   168201      -35     
- Misses      11204    11215      +11     
- Partials     7194     7218      +24     
Files with missing lines Coverage Δ
lib/internal/test_runner/runner.js 89.03% <100.00%> (ø)
lib/internal/test_runner/utils.js 60.46% <66.66%> (ø)

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marco-ippolito
Copy link
Member

Currently all the release line supporting typescript follow the same behavior.
Since v24 will be the first LTS with strip types enable by default I would like to be cautious and leave the current behavior, which minimizes the risk of breaking change.

@theoludwig
Copy link
Contributor Author

Currently all the release line supporting typescript follow the same behavior.

That's not the case, all release lines do not follow the same behavior. With the following structure:

├── src
│   ├── dates.ts
│   ├── strings.ts
│   ├── tests
│   │   ├── dates.test.ts
│   │   ├── strings.test.ts
├── package.json
├── tsconfig.json

And with package.json:

{
  "scripts": {
    "test": "node --experimental-strip-types --test"
  }
}

Running node --run test in Node.js v22 results in:

 tests 53
 suites 20
 pass 53
 fail 0
 cancelled 0
 skipped 0
 todo 0
 duration_ms 175.004645

Running node --run test in Node.js v24 results in:

 tests 0
 suites 0
 pass 0
 fail 0
 cancelled 0
 skipped 0
 todo 0
 duration_ms 15.541625

@theoludwig
Copy link
Contributor Author

Since v24 will be the first LTS with strip types enable by default I would like to be cautious and leave the current behavior, which minimizes the risk of breaking change.

That's the opportunity, to make the good defaults. Weird, that you consider this breaking, you should have considered #56350 breaking then.

It will be even more painful, if we do it later. And again, I don't understand why someone would transpile their TypeScript test files, if they can execute them directly. And even if they do, they will at least be executed, and the only "bad thing", the tests will be included twice, whereas, I assume most people, would want to execute their test files, it will be ignored which is worst IMO, than executing twice (of course executing twice is also not the correct behavior), at least the tests runs.

@marco-ippolito
Copy link
Member

Apparently it has not been backported to v22 yet. I'm really not sure what to do 🤷 either way some use cases are gonna break

pinging @nodejs/tsc

@marco-ippolito
Copy link
Member

marco-ippolito commented May 8, 2025

I thought about it and I'm ok with reverting. It caused more trouble than it solved.
Can you create a revert commit rather than a new one?

@theoludwig theoludwig force-pushed the test_runner/typescript-glob branch from 080797a to 95d88b8 Compare May 8, 2025 14:07
@theoludwig theoludwig changed the title test_runner: glob TypeScript files same as with JavaScript files Revert "test_runner: change ts default glob" May 8, 2025
@marco-ippolito marco-ippolito added the notable-change PRs with changes that should be highlighted in changelogs. label May 8, 2025
Copy link
Contributor

github-actions bot commented May 8, 2025

The notable-change PRs with changes that should be highlighted in changelogs. label has been added by @marco-ippolito.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

@marco-ippolito
Copy link
Member

Added notable change because it was requested that we highlight this change since its a breaking change for people using experimental strip types

@marco-ippolito marco-ippolito added the request-ci Add this label to start a Jenkins CI on a PR. label May 8, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 8, 2025
@nodejs-github-bot
Copy link
Collaborator

@marco-ippolito marco-ippolito added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels May 9, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 9, 2025
@nodejs-github-bot nodejs-github-bot merged commit 264cad7 into nodejs:main May 9, 2025
68 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 264cad7

@theoludwig theoludwig deleted the test_runner/typescript-glob branch May 9, 2025 10:34
targos pushed a commit that referenced this pull request May 16, 2025
This reverts commit 9df0ff7.

PR-URL: #58202
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
@marco-ippolito marco-ippolito added the dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. label May 19, 2025
@marco-ippolito marco-ippolito added dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. strip-types Issues or PRs related to strip-types support labels May 19, 2025
nodejs-github-bot added a commit that referenced this pull request May 20, 2025
Notable changes:

doc:
  * add JonasBa to collaborators (Jonas Badalic) #58355
  * add puskin to collaborators (Giovanni Bucci) #58308
fs:
  * (SEMVER-MINOR) add to `Dir` support for explicit resource management (Antoine du Hamel) #58206
test_runner:
  * Revert "test_runner: change ts default glob (Théo LUDWIG) #58202

PR-URL: #58406
aduh95 pushed a commit that referenced this pull request May 21, 2025
Notable changes:

doc:
  * add JonasBa to collaborators (Jonas Badalic) #58355
  * add puskin to collaborators (Giovanni Bucci) #58308
fs:
  * (SEMVER-MINOR) add to `Dir` support for explicit resource management (Antoine du Hamel) #58206
test_runner:
  * Revert "test_runner: change ts default glob (Théo LUDWIG) #58202

PR-URL: #58406
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. strip-types Issues or PRs related to strip-types support test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants