-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Add test runner configuration #48852
Comments
this was raised before some people had concerns, but I am definitely +1 on this @nodejs/test_runner WDYT? |
This came up recently in #48425 (comment). See also https://github.com/orgs/nodejs/discussions/44975 and #43973 (the latter is very similar to this feature request). I would love to see Node be configurable via Footnotes
|
I'm +0.5, but can someone make the case of what's the difference between having a config file that also calls |
It makes sense to me to support more options than just those for the test runner. I am not familiar with Node internals, so if parsing JSON is hard at the level it’s needed, I’m inclined to believe whatever you tell me. I am personally just not a fan of NODE_TEST_REPORTER='@reporters/junit spec'
NODE_TEST_REPORTER_DESTINATION='junit.xml stdout'
One useful feature of Also if such a configuration is standardized, third party integrations such as editor integrations could read this configuration. If we take the configuration a bit further, it could look like this: {
"scripts": {
"test": "c8 node --test"
},
"test": {
"loaders": ["tsx"],
"testNamePatterns": "test/*.ts"
"reporters": {
"@reporters/junit": "junit.xml",
"spec": "stdout"
}
}
} This would tell all integrations to use the |
Strongly -1 for extending package.json or another kind of 'hardcoded' config. My own 'test-runner' implementation is about 100 lines for all: test.config.xxx (js, mjs or ts) parsing, setup ESM loaders, collecting coverage via c8 Report class, choosing right reporters for CI, etc. Everyone can write something similar and publish as NPM package. Moreover, we can ask @MoLow to add his own implementation (with package.json support or whatever) following the example of 'reporters' repo, which can be used as default solution for 80% of Node users. Sometimes this configuration tool may come bundled with Node, or deprecated in favour of 'full-featured configuration system for Node' in 2030.
It accepts - trough 'setup' callback: root.reporter.compose(reporter).pipe(your destination). |
I am pretty sure this is something that cannot happen in userland. flags are parsed before execution of any js code |
You are definitely right... for regular Node usage. But 'run' is a bit different thing: each test file executed as separate process, so we can specify any options via process.env.NODE_OPTIONS = '...' then call 'run' - and it works. |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment. For more information on how the project manages feature requests, please consult the feature request management document. |
What is the problem this feature will solve?
Currently the test runner can be configured using command line arguments and / or a custom script that calls
run()
. These commands can get long, making them hard to read. For example:What is the feature you are proposing to solve the problem?
I propose to add the key
test
topackage.json
. Runningnode --test
will read this key and merge the configuration with other configuration options. Thetest
key accepts the same options asrun()
, plus thereporters
field, which is a key-value pair of reporters and their output file.The above example, could be changed to:
This makes it nicer to work with TypeScript interpreters. (Refs privatenumber/tsx#257.) For example:
The
test
field can also be defined using a JSON schema (outside of Node.js), so editors get validation and completion.What alternatives have you considered?
It could be defined in a separate file. I think a key in
package.json
makes sense though, because it’s already used to configure Node.js.The text was updated successfully, but these errors were encountered: