Skip to content

Conversation

@JakobJingleheimer
Copy link
Member

A follow-up to the discussion in the 26 Jan 2026 team meeting

node
--test ./src/foo/*.test.js
--test ./src/bar/*.test.js
./src/not-pjson-main.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would the purpose of this be? The test runner runs for the two glob patterns and then does what with this entry point script? Executes it as a test too or just as a regular node script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, true. Let's say there is no such thing as an entry-point for test mode (I think that doesn't exist currently either). If there's any "entry-point" when --test is present, throw.

I think in order to run an arbitrary script, it should be done with --import (and friends); otherwise, you get into inception.

node
  --import ./test/env.setup.js
  --import ./test/fix-snapshot-naming.js
  --test ./src/foo/*.test.js
  --test ./src/bar/*.test.js

./src/not-pjson-main.js
```

An explicit entrypoint, like all node commands, must come last and must be a relative or absolute path (not a glob/pattern).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this tracks for test. Many users will only want to pass a single glob pattern; at least I know that I do! What would the explicit entry point do for a test script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay, fair. So when watch mode is combined with test mode, shall we say that entry-point is not applicable—it's only applicable for watch mode separately?

@cjihrig
Copy link

cjihrig commented Feb 9, 2026

How will this work across versions? Please don't underestimate the pain that inconsistencies in the test runner CLI across versions cause for users (ie glob support). It takes years for these pain points to go away.

@JakobJingleheimer
Copy link
Member Author

@cjihrig we discussed in today's meeting. I'm about to update this with the 3rd option that was born from that. I'll ping you for review in a few minutes.

@cjihrig
Copy link

cjihrig commented Feb 9, 2026

Discussed with @JakobJingleheimer and apparently it will not break existing users, so 👍

@JakobJingleheimer
Copy link
Member Author

I think "option 3" will actually JustWork? --test is eager/hungry, so

node
  --test ./foo.test.js
  --test ./bar.test.js

currently results in:

[
  './foo.test.js',
  '--test',
  './bar.test.js',
]

--test is nonsense for a value, and it currently gets discarded (all flags after --test do).

We can backport support for --watch-path (that’s nonbreaking); it would just continue to not work in older versions if supplied after --test.

Copy link
Contributor

@Ethan-Arrowood Ethan-Arrowood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still seeing some parts of this talking about main entrypoints with the test runner which just doesn't make sense. I'd prefer we clean that up before merging this as that may only cause more confusion in further discussions.

`--watch` currently does 2 things:

* enables `watch` mode
* optionally accepts 1 value to override the entrypoint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* optionally accepts 1 value to override the entrypoint
* optionally accepts 1 value to override the entrypoint
* and the `--watch-path` option is used for any additional paths to include besides the entrypoint

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: those bullet-points are about --watch, so i think --watch-path should be separate

Suggested change
* optionally accepts 1 value to override the entrypoint
* optionally accepts 1 value to override the entrypoint
`--watch-path` sets additional paths (can be set multiple times) to include as well as the entrypoint.

Comment on lines +171 to +183
`test` would then work the same way:

```sh title='reads "main" etc from package.json'
node --test
```
```sh title='package.json "main" + an additional path'
node --test ./src/**/*.test.js
```
```sh title='explicit entrypoint + an additional path'
node
--test ./src/foo/*.test.js
--test ./src/bar/*.test.js
./src/not-pjson-main.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this section still needs to be updated, no? Test runs don't use main entrypoint or any entrypoint for that matter. It uses file patterns matching test files.

Comment on lines +198 to +199
--watch
./src/not-pjson-main.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe an newline character would change the CLI parsing here. This is the same as specifying a path for --watch. Or am I mistaken?

@JakobJingleheimer
Copy link
Member Author

I'm still seeing some parts of this talking about main entrypoints with the test runner which just doesn't make sense. I'd prefer we clean that up before merging this as that may only cause more confusion in further discussions.

Are you talking about the other options besides the one added yesterday? If so, my plan was to wait for people to weigh in; once one is selected, update the proposal to move the discard ones to a new "Rejected" section, and outdent the selected option.

If you're talking about the small bit mentioning --watch's value being discarded, doesn't that align with what you just said?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants