Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
Description
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:
{"scripts":{"test": "c8 node --test --test-reporter @reporters/junit --test-reporter-destination=junit.xml --test-reporter spec --test-reporter-destination stdout" } }What is the feature you are proposing to solve the problem?
I propose to add the key test to package.json. Running node --test will read this key and merge the configuration with other configuration options. The test key accepts the same options as run(), plus the reporters field, which is a key-value pair of reporters and their output file.
The above example, could be changed to:
{"scripts":{"test": "c8 node --test" }, "test":{"reporters":{"@reporters/junit": "junit.xml", "spec": "stdout" } } }This makes it nicer to work with TypeScript interpreters. (Refs privatenumber/tsx#257.) For example:
{"scripts":{"test": "c8 tsx --test" }, "test":{"testNamePatterns": "test/*.ts""reporters":{"@reporters/junit": "junit.xml", "spec": "stdout" } } }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.